CAMBRIDGE IGCSE COMPUTER SCIENCE
February/March 2023 · Paper 22 · Question 11 · 15 marks
← 0478 CS Hub Paper 22 · Feb/March 2023 0478 / Paper 2 Question 11 15 MARKS
15-mark question lab · start here

From a grid of match points to a full league table.

Build the solution in a sensible order: decode the five requirements, plan the totals array and the four counters, zero everything at the right loop level, total each team’s points, count the four result types, output every team’s line, then crown the top and bottom teams. Learn the reasoning before revealing the complete program.

2D array accessNested loopsTotallingCounting four result typesFinding max and min15 marks

Learning targets

By the end, you should be able to explain the algorithm before writing it.

Lesson overview

01 · Understand

Identify the given arrays TeamName[] and TeamPoints[], the variables LeagueSize and MatchNo, the 3–2–1–0 points system and the five requirements hidden in the bullet list.

02 · Construct

Build the program in order: zero the totals array, then nested loops that total each team’s points and use CASE OF to count away wins, home wins, drawn matches and lost matches, outputting every team’s six lines.

03 · Complete

Track the highest and lowest totals with strict tests that store the champion indices, then output the top and bottom team names through TeamName[].

!

How Cambridge awards the marks: the mark scheme gives AO2 a maximum of 9 marks and AO3 a maximum of 6 marks. It lists requirements R1–R5, but does not assign a separate fixed mark total to each R requirement. The stage-to-mark links in this guide show alignment, not invented stage marks.

Source question

Read the whole question first

Do not begin coding after the first paragraph. The 3–2–1–0 points system, the parallel arrays and the two champion outputs all affect the structure of your solution.

Question 11 · 15 marks
Cambridge IGCSE Computer Science · 0478/22 · Question 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

Before you move on

These are the five required techniques identified by the Cambridge mark scheme.

Mark-scheme map
R1

Calculate the total points for all matches played by each team — nested iteration over teams and matches with totalling.

R1

Accumulate into a parallel totals array so every team’s total survives for the output line and the champion comparisons.

R2

Count the total number of away wins, home wins, drawn matches and lost matches for each team — nested iteration and counting.

R2

Output, with the team’s name, each team’s total points and four counts with suitable messages — output.

R3

Find and output the names of the teams with the highest and the lowest total points — selection and output.

Use the tabs along the top to work through the seven stages. The complete solution is kept in its own tab, and the interactive visualisation is the final tab.