0% found this document useful (0 votes)
139 views3 pages

Teams - 15 Marks Que

The program calculates the total points and match results (away wins, home wins, draws, losses) for each team. It outputs these details for each team, and finds the team with the highest total points and lowest total points. It uses nested for loops to iterate through the team name and points arrays, calculating totals and results for each team.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views3 pages

Teams - 15 Marks Que

The program calculates the total points and match results (away wins, home wins, draws, losses) for each team. It outputs these details for each team, and finds the team with the highest total points and lowest total points. It uses nested for loops to iterate through the team name and points arrays, calculating totals and results for each team.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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
RowCount0
ColCount0
DECLARE AwayWinsCount, HomeWinsCount, DrawsCount, LossCount, TotalPoints,
HighestPoints, LowestPoints : INTEGER
DECLARE HighestTeamIndex, LowestTeamIndex : INTEGER
TotalPoints0
HighestPoints0
LowestPoints12

FOR RowCount1 TO 5
FOR ColCount1 TO 4
TotalPointsTotalPoints+TeamPoints(RowCount,ColCount)
IF TeamPoints(RowCount,ColCount) =3 THEN
AwayWinsCountAwayWinsCount+1
ELSE IF TeamPoints(RowCount,ColCount)=2 THEN
HomeWinsCountHomeWinsCount+1
ELSEIF TeamPoints(RowCount,ColCount)=1 THEN
DrawsCountDrawsCount+1
ELSEIF TeamPoints(RowCount,ColCount)=0 THEN
LossCountLossCount+1
ENDIF
NEXT ColCount

IF TotalPoints>HighestPoints THEN
HighestPointsTotalPoints
HighestTeamIndexRowCount
ENDIF
IF TotalPoints<LowestPoints THEN
LowestPointsTotalPoints
LowestTeamIndexRowCount
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

You might also like