CAMBRIDGE IGCSE COMPUTER SCIENCE
2023 Specimen Paper 2B · Question 14 · 15 marks
← 0478 CS Hub Specimen 2B · 2023 0478 / Paper 2 Question 14 15 MARKS
15-mark question lab · start here

From a cinema seat map to a booked ticket.

Build the solution in a sensible order: understand the seat data, count what is still available, total the money already collected, find the row with the most free seats, validate the customer's request and book the seat. Learn the reasoning before revealing the complete program.

2D arraysNested iterationMaximum trackingValidation and booking15 marks

Learning targets

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

Lesson overview

01 · Understand

Identify the two 2D arrays, their shared row-and-seat indexes, and the values already supplied.

02 · Construct

Use nested loops to count the available seats in each row and total the money from booked seats.

03 · Complete

Track the row with the most available seats, validate the requested seat, book it and output every required result.

!

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 two arrays, the validation ranges and the booking rules all affect the structure of your solution.

Question 14 · 15 marks
Cambridge IGCSE Computer Science · 0478/02 · Question 14

A cinema has seats arranged in rows. The two-dimensional (2D) array SeatTaken[] contains, for every seat, the value TRUE if the seat has already been booked and FALSE if the seat is still available. The first index gives the row number and the second index gives the seat number within the row. For example, SeatTaken[3, 7] refers to seat 7 in row 3.

The two-dimensional (2D) array SeatPrice[] contains the price of every seat. The two arrays use the same row and seat indexes, so SeatPrice[3, 7] is the price of seat 7 in row 3.

The variable RowNo contains the number of rows. The variable SeatsInRow contains the number of seats in each row. Every row has the same number of seats.

The arrays and variables have already been set up and the data stored.

Write a program that meets the following requirements:

  • counts and outputs the number of seats still available in each row
  • calculates and outputs the total number of seats still available in the whole cinema
  • calculates and outputs the total amount of money already collected from all the booked seats
  • finds and outputs the number of the row with the most seats still available
  • asks the user to input the row number and the seat number of the seat they want to book; both inputs must be validated as within the correct range
  • if the requested seat is still available, books the seat, outputs the price of the seat and outputs the new total number of seats available in the whole cinema; if the requested seat is already booked, outputs a suitable message.

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

You do not need to initialise the data in the arrays.

Before you move on

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

Mark-scheme map
R1

Count the seats still available in each row using iteration and counting.

R2

Total the available seats for the whole cinema and the money collected from booked seats.

R3

Find the row with the most available seats using maximum tracking.

R4

Input and validate the requested row and seat numbers.

R5

Book the seat when it is available and output the price and the updated total, or a suitable message when it is taken.

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.