CAMBRIDGE IGCSE COMPUTER SCIENCE
Winter 2024 · Paper 22 · Question 12 · 15 marks
← 0478 CS Hub Paper 22 · Winter 2024 0478 / Paper 2 Question 12 15 MARKS
15-mark question lab · start here

From room measurements to a full house area report.

Build the solution in a sensible order: input and validate the room count, take every room’s name, length and width, store each area rounded to two decimal places, track the largest and smallest rooms, then print the complete report with the house totals. Learn the reasoning before revealing the complete program.

1D + 2D arraysInput validationROUND to 2 dpLargest and smallestParallel indexes15 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 and their shared room index, and see that this program inputs everything itself: the number of rooms and every room’s name, length and width.

02 · Construct

Build the validation loop for the room count (at least 3, no more than 20), then store each area as length multiplied by width, rounded to two decimal places with ROUND(x, 2).

03 · Complete

Track the largest and smallest rooms by area while the data is entered, then output the full table, the champion names and the total and average areas to two decimal places.

!

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 shared room index, the two-decimal rounding and the three-part output section all shape the structure of your answer.

Question 12 · 15 marks
Cambridge IGCSE Computer Science · 0478/22 · Question 12

A one-dimensional (1D) array Rooms[] contains the names of up to 20 rooms in a house. A two-dimensional (2D) array Dimensions[] is used to store the length, width and area of each room.

The position of any room’s data is the same in both arrays. For example, the data in index 5 of Dimensions[] belongs to the room in index 5 of Rooms[]

The variable Number stores the number of rooms for which data is to be input. There must be at least 3 rooms but no more than 20.

Write a program that meets the following requirements:

  • allows the number of rooms for which data is required to be input, stored and validated
  • allows the name of the room and the length and width of the room, in metres, to be entered and stored
  • allows the area of each room to be calculated as length multiplied by width and stored as square metres rounded to two decimal places
  • calculates the average size of all the rooms by area, in square metres, rounded to two decimal places
  • finds the largest room and smallest room by area
  • outputs the names of all rooms with their dimensions and area
  • outputs the names of the largest room and smallest room by area
  • outputs the total area of the house and the average size of all the rooms by area.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays or variables; 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 the number of rooms into Number and validate it against the inclusive range 3 to 20 before any room data is taken.

R2

Input each room’s name into Rooms[] and its length and width in metres into Dimensions[,], keeping the two arrays parallel by index.

R3

Calculate each area as length multiplied by width and store it in the third column of Dimensions[,] rounded to two decimal places with ROUND(x, 2).

R4

Track the largest and smallest rooms by area while the rooms are entered, storing each champion’s area and name together.

R5

Output every room with its dimensions and area, the largest and smallest room names, and the total and average areas rounded to two decimal places.

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.