CAMBRIDGE IGCSE COMPUTER SCIENCE
Summer 2024 · Paper 23 · Question 9 · 15 marks
← 0478 CS Hub Paper 23 · Summer 2024 0478 / Paper 2 Question 9 15 MARKS
15-mark question lab · start here

From match records to the league champion.

Build the solution in a sensible order: input and validate the games played, store the ten team names, collect each team's won, drawn and lost record against Played, calculate and store the points, bubble sort the table into descending order with Teams[] kept parallel, then report every team sharing the highest points. Learn the reasoning before revealing the complete program.

1D + 2D arraysParallel arraysREPEAT-UNTIL validationPoints formulaDescending bubble sort15 marks

Learning targets

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

Lesson overview

01 · Understand

Identify the two arrays, the four Results[] columns and the single Played variable — and recognise that nothing is pre-stored: this program inputs everything itself.

02 · Construct

Use REPEAT … UNTIL loops to validate the games played against the 18 maximum and each team's won + drawn + lost against Played, then store won × 3 + drawn in column 4.

03 · Complete

Bubble sort Results[] into descending points order while swapping the parallel Teams[] in step, count the teams on the highest points and output the champion(s).

!

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 18-game maximum, the sum-must-equal-Played validation and the parallel-array sort all affect the structure of your solution.

Question 9 · 15 marks
Cambridge IGCSE Computer Science · 0478/23 · Question 9

A one-dimensional (1D) array Teams[] contains the names of 10 football teams in a local league. A two-dimensional (2D) array Results[] stores, for each team, the total number of:

  • games won
  • games drawn
  • games lost
  • points.

The position of any team’s data is the same in both arrays. For example the data in index 3 of Results[] belongs to the team in index 3 of Teams[]

The array data will be used to find the current leader of the league. The variable Played stores the number of games played by each team. Each team plays the same number of games.

Write a program that meets the following requirements:

  • allows the number of games played to be input and stored, with a maximum of 18 games
  • allows the names of the teams to be input and stored
  • allows the number of games won, drawn and lost to be input and stored for each team
  • validates the number of games played and the number of games won, drawn or lost against the number of games played
  • calculates and stores the number of points for each team using three points for a win and one point for a draw; there are no points for a loss
  • sorts the array Results[] into descending order of number of points, ensuring the corresponding parallel array Teams[] is kept in the same order
  • determines how many teams have the highest number of points
  • outputs the name(s) of the winning team(s) along with the number of points achieved.

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.

Before you move on

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

Mark-scheme map
R1

Input and store the number of games played with validation against the maximum of 18, then input and store the ten team names.

R2

Input each team's won, drawn and lost record and validate it against Played — the three totals must sum to Played, with a re-entry on mismatch.

R3

Calculate and store each team's points in Results[TeamCounter, 4]: three for a win, one for a draw, nothing for a loss.

R4

Bubble sort Results[] into descending order of points, swapping all four columns and the parallel Teams[] entry together.

R5

Count how many teams share the highest points and output the winning team name(s) with the points achieved.

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.