The one-dimensional (1D) array TeamName[] contains the names of teams in a sports league.
string[] TeamName = { "Real Madrid", "Barcelona", "Bayern Munich", "Juventus", "Paris Saint-Germain" };The two-dimensional (2D) array TeamPoints[] contains the points awarded for each match.
int[,] TeamPoints = new int[,]
{
{ 2, 1, 0, 3, 2 }, // Points for Team A in 5 matches
{ 1, 3, 1, 0, 2 }, // Points for Team B in 5 matches
{ 0, 1, 1, 1, 3 }, // Points for Team C in 5 matches
{ 2, 0, 3, 1, 1 }, // Points for Team D in 5 matches
{ 3, 2, 1, 0, 0 } // Points for Team E in 5 matches
};The position of each team’s data in the two arrays is the same. For example, the team stored at index 4 in TeamName[] and TeamPoints[] is the same. The variable LeagueSize contains the number of teams in the league. The variable MatchNo contains the number of matches played. All teams have played the same number of matches. The arrays and variables have already been set up and the data stored. Each match can be played at home or away.
Points are recorded for the match results of each team with the following values:
- 3 – away win
- 2 – home win
- 1 – drawn match
- 0 – lost match.
Here are the 5 tasks you should complete based on the above information.
- Write a method named CalculateTotalPoints that calculates the total points for all matches played for each team.
- Write a method named CountMatchResults that counts the total number of away wins, home wins, drawn matches, and lost matches for each team.
- Write a method named OutputTeamInfo that outputs the name, total points, and the number of away wins, home wins, drawn matches, and lost matches for each team.
- Write a method
- FindTeamWithHighestPoints that finds and outputs the name of the team with the highest total points.
- FindTeamWithLowestPoints that finds and outputs the name of the team with the lowest total points.
- Write a method named GetTeamStats that takes the name of a team as a parameter and returns a string containing the team's total points, number of away wins, home wins, drawn matches, and lost matches. The string should be formatted in a readable manner.
Submit your work as .cs file and a pdf file that includes your whole code.

Lokesh VarmanRank #374 · 6.8K reputationPosted Jul 4, 2023, 10:42 AM EDT
using System; class Program { static string[] TeamName = { "Real Madrid", "Barcelona", "Bayern Munich", "Juventus", "Paris Saint-Germain" }; static int[,] TeamPoints = new int[,] { { 2, 1, 0, 3, 2 }, // Points for Team A in 5 matches { 1, 3, 1, 0, 2 }, // Points for Team B in 5 matches { 0, 1, 1, 1, 3 }, // Points for Team C in 5 matches { 2, 0, 3, 1, 1 }, // Points for Team D in 5 matches { 3, 2, 1, 0, 0 } // Points for Team E in 5 matches }; static int LeagueSize = TeamName.Length; static int MatchNo = TeamPoints.GetLength(1); static void Main() { CalculateTotalPoints(); CountMatchResults(); OutputTeamInfo(); FindTeamWithHighestPoints(); FindTeamWithLowestPoints(); string teamStats = GetTeamStats("Barcelona"); Console.WriteLine(teamStats); } static void CalculateTotalPoints() { int[] totalPoints = new int[LeagueSize]; for (int i = 0; i maxPoints) { maxPoints = teamTotalPoints; teamWithMaxPoints = TeamName[i]; } } Console.WriteLine("Team with the highest points: " + teamWithMaxPoints); } static void FindTeamWithLowestPoints() { int minPoints = int.MaxValue; string teamWithMinPoints = ""; for (int i = 0; i < LeagueSize; i++) { int teamTotalPoints = 0; for (int j = 0; j < MatchNo; j++) { teamTotalPoints += TeamPoints[i, j]; } if (teamTotalPoints < minPoints) { minPoints = teamTotalPoints; teamWithMinPoints = TeamName[i]; } } Console.WriteLine("Team with the lowest points: " + teamWithMinPoints); } static string GetTeamStats(string teamName) { int teamIndex = Array.IndexOf(TeamName, teamName); if (teamIndex != -1) { int teamTotalPoints = 0; int awayWins = 0; int homeWins = 0; int drawnMatches = 0; int lostMatches = 0; for (int j = 0; j < MatchNo; j++) { int points = TeamPoints[teamIndex, j]; teamTotalPoints += points; if (points == 3) awayWins++; else if (points == 2) homeWins++; else if (points == 1) drawnMatches++; else lostMatches++; } string teamStats = string.Format( "Team Name: {0}\nTotal Points: {1}\nAway Wins: {2}\nHome Wins: {3}\nDrawn Matches: {4}\nLost Matches: {5}", teamName, teamTotalPoints, awayWins, homeWins, drawnMatches, lostMatches); return teamStats; } return "Team not found."; } }Sample Output -
Team Name: Real Madrid
Team Name: Barcelona
Team Name: Bayern Munich
Team Name: Juventus
Team Name: Paris Saint-Germain
Team with the highest points: Real Madrid
Team with the lowest points: Bayern Munich
Team Name: Barcelona
Total Points: 7
Away Wins: 1
Home Wins: 1
Drawn Matches: 2
Lost Matches: 1
Hope it helps ! PS: Go through all the methods
Amit MohantyRank #112 · 20K reputationPosted Jul 5, 2023, 2:07 AM EDT
using System; namespace MyConsoleApp { class SportsLeague { static string[] TeamName = { "Real Madrid", "Barcelona", "Bayern Munich", "Juventus", "Saint-Germain" }; static int[,] TeamPoints = new int[,] { { 2, 1, 0, 3, 2 }, { 1, 3, 1, 0, 2 }, { 0, 1, 1, 1, 3 }, { 2, 0, 3, 1, 1 }, { 3, 2, 1, 0, 0 } }; static int LeagueSize = TeamName.Length; static int MatchNo = TeamPoints.GetLength(1); public static void ShowResult() { OutputTeamInfo(); Console.WriteLine(); string teamWithHighestPoints = FindTeamWithHighestPoints(); Console.WriteLine("Team with the highest total points: " + teamWithHighestPoints); string teamWithLowestPoints = FindTeamWithLowestPoints(); Console.WriteLine("Team with the lowest total points: " + teamWithLowestPoints); Console.WriteLine(); string teamStats = GetTeamStats("Bayern Munich"); Console.WriteLine("Bayern Munich's stats: "); Console.WriteLine(teamStats); } static void CalculateTotalPoints(out int[] totalPoints) { totalPoints = new int[LeagueSize]; for (int teamIndex = 0; teamIndex maxPoints) { maxPoints = totalPoints[teamIndex]; maxPointsIndex = teamIndex; } } return TeamName[maxPointsIndex]; } static string FindTeamWithLowestPoints() { int[] totalPoints; CalculateTotalPoints(out totalPoints); int minPoints = int.MaxValue; int minPointsIndex = -1; for (int teamIndex = 0; teamIndex < LeagueSize; teamIndex++) { if (totalPoints[teamIndex] < minPoints) { minPoints = totalPoints[teamIndex]; minPointsIndex = teamIndex; } } return TeamName[minPointsIndex]; } static string GetTeamStats(string teamName) { int teamIndex = Array.IndexOf(TeamName, teamName); if (teamIndex == -1) return "Team not found."; int[] totalPoints; CalculateTotalPoints(out totalPoints); int[,] matchResults; CountMatchResults(out matchResults); int teamTotalPoints = totalPoints[teamIndex]; int awayWins = matchResults[teamIndex, 0]; int homeWins = matchResults[teamIndex, 1]; int drawnMatches = matchResults[teamIndex, 2]; int lostMatches = matchResults[teamIndex, 3]; string teamStats = string.Format("Total Points: {0}\nAway Wins: {1}\nHome Wins: {2}\nDrawn Matches: {3}\nLost Matches: {4}", teamTotalPoints, awayWins, homeWins, drawnMatches, lostMatches); return teamStats; } } }cjard43 reputationPosted Jul 5, 2023, 4:33 AM EDT
Oh, I didn't realize c-sharpcorner was a "do your homework" service...
You should really have a go at it yourself, then post up a question about some partyou're having trouble with, not the whole thing..