11 The one-dimensional (1D) array TeamName[] contains the names of teams in a sports
league. The two-dimensional (2D) array TeamPoints[] contains the points awarded for each
match. The position of each team’s data in the two arrays is the same. For example, the team
stored at index 10 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.
Write a program that meets the following requirements:
• calculates the total points for all matches played for each team
• counts the total number of away wins, home wins, drawn matches and lost matches for each
team
• outputs for each team:
– name
– total points
– total number of away wins, home wins, drawn matches and lost matches
• finds and outputs the name of the team with the highest total points
• finds and outputs the name of the team with the lowest total points.
You must use pseudocode or program code and add comments to explain how your code
works.
You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.
All inputs and outputs must contain suitable messages.
You do not need to initialise the data in the arrays TeamName[] and TeamPoints[] or the
variables LeagueSize and MatchNo
Index TeamName
1 Liverpool
2 ManU
3 Chelsea
4 Barcelona
5 Arsenal
Team Points
Index 1 2 3 4
1 2 1 0 0
2 0 0 0 1
3 0 0 0 0
4 3 3 3 3
5 2 1 3 0
START
DECLARE TeamName : ARRAY[1 TO 5] OF STRING={“Liverpool”,
“ManU”,”Chelsea”,”Barcelona”, “Arsenal”}
DECLARE TeamPoints : ARRAY[1 TO 5, 1 TO 4] OF INTEGER={(2,1,0,0),(0,0,0,1),( 0,0,0,0),
(3,3,3,3),(2,1,3,0)}
DECLARE LeagueSize : INTEGER=5
DECLARE MatchNo : INTEGER=4
DECLARE RowCount : INTEGER
DECLARE ColCount : INTEGER
RowCount0
ColCount0
DECLARE AwayWinsCount, HomeWinsCount, DrawsCount, LossCount, TotalPoints,
HighestPoints, LowestPoints : INTEGER
DECLARE HighestTeamIndex, LowestTeamIndex : INTEGER
TotalPoints0
HighestPoints0
LowestPoints12
FOR RowCount1 TO 5
FOR ColCount1 TO 4
TotalPointsTotalPoints+TeamPoints(RowCount,ColCount)
IF TeamPoints(RowCount,ColCount) =3 THEN
AwayWinsCountAwayWinsCount+1
ELSE IF TeamPoints(RowCount,ColCount)=2 THEN
HomeWinsCountHomeWinsCount+1
ELSEIF TeamPoints(RowCount,ColCount)=1 THEN
DrawsCountDrawsCount+1
ELSEIF TeamPoints(RowCount,ColCount)=0 THEN
LossCountLossCount+1
ENDIF
NEXT ColCount
IF TotalPoints>HighestPoints THEN
HighestPointsTotalPoints
HighestTeamIndexRowCount
ENDIF
IF TotalPoints<LowestPoints THEN
LowestPointsTotalPoints
LowestTeamIndexRowCount
ENDIF
OUTPUT “Team: ”, TeamName(RowCount)
OUTPUT “Points: “, TotalPoints
OUTPUT “Away Wins: “, AwayWinsCount
OUTPUT “Home Wins: “, HomeWinsCount
OUTPUT “Draws: “, DrawsCount
OUTPUT “Loss: “, LossCount
NEXT RowCount
OUTPUT “Team with highest points is: “, TeamName(HighestTeamIndex)
OUTPUT “and the highest points is: “,HighestPoints
OUTPUT “Team with Lowest points is: “, TeamName(LowestTeamIndex)
OUTPUT “and the lowest points is: “, LowestPoints
END