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

From room measurements to a stored, priced wood quotation.

Build the solution in a sensible order: decode the requirements, plan the arrays, initialise the wood tables, input and validate the measurements, round the area up, choose the wood and find its price, then store and output the quotation. Learn the reasoning before revealing the complete program.

Input validationRange check 1.5–10.0Rounding upArray lookup2D array storage15 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 Customers[] and Quotations[] with its five columns, the wood tables WoodType[] and Price[] you must initialise yourself, the inclusive 1.5–10.0 measurement range and the nine requirement bullets.

02 · Construct

Build the program in order: populate the wood arrays, then inside WHILE Cont — input and validate the name, length and width, round the area up to the next whole number, choose the wood, retrieve its price and calculate the cost.

03 · Complete

Store all five values in the columns of Quotations[], output each customer’s quotation — name, choice of wood and calculated price — with suitable messages, and continue to accept the next customer.

!

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 five columns of Quotations[], the inclusive 1.5–10.0 range and the two arrays you must initialise yourself all affect the structure of your solution.

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

A wood flooring company stores the names of up to 100 customers in a one-dimensional (1D) array Customers[]. A two-dimensional (2D) array Quotations[] stores details of each customer’s quotation:

  • length of room (one decimal place)
  • width of room (one decimal place)
  • area of wood required (rounded up to next whole number)
  • choice of wood index (whole number)
  • price of wood required in dollars (two decimal places).

The floor measurements (room length and room width) are taken in metres. All floors are rectangles and room measurements must be between 1.5 and 10.0 inclusive.

The index of any customer’s data is the same in both arrays. For example, a customer named in index 4 of Customers[] corresponds to the data in index 4 of Quotations[]

The wood choices available are:

  • Index 1 — wood type Laminate — price per square metre $29.99
  • Index 2 — wood type Pine — price per square metre $39.99
  • Index 3 — wood type Oak — price per square metre $54.99.

The data are stored in two 1D arrays named WoodType[] and Price[]. The index of the wood type and price in their arrays share the same index number.

Write a program that meets the following requirements:

  • input a new customer’s name, room length and room width
  • check that each measurement is valid
  • output an error message and require the measurement to be re-entered until it is valid
  • calculate the area of the room by multiplying together the length of the room and the width of the room
  • input the choice of wood and find its price per square metre
  • calculate the price of the wood needed
  • store all data in the relevant array
  • output the customer’s quotation to include: the name of the customer, the choice of wood and the calculated price of the wood required
  • continue to accept the next customer.

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.

You will need to initialise WoodType[] and Price[]

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 customer’s name, room length and room width, with validation of the room dimensions — input with prompts, range check and iteration.

R1

Output an error message and require each measurement to be re-entered until it is valid — the WHILE validation loop that repeats the input.

R2

Initialise the wood arrays, calculate the room area and round it up to the next whole number, then select the wood, retrieve its price and calculate the price of the wood — array initialisation, rounding, data retrieval from array, calculation.

R2

Round and store all data in the relevant array — the five columns of Quotations[] receive length, width, area, wood index and price.

R3

Output the full details — name of customer, choice of wood and quotation price with appropriate messages — and continue for the next customer — output with messages, iteration of the whole program.

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.