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

From a Boolean seat grid to bookings, refusals and a full house.

Build the solution in a sensible order: decode the five requirements, plan the counters and constants, count the booked seats with nested loops, input and validate the request, then allocate seats in order or report exactly why you cannot. Learn the reasoning before revealing the complete program.

2D Boolean arrayNested iteration and countingInput validationSelection and assignmentRow-major allocation15 marks

Learning targets

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

Lesson overview

01 · Understand

Identify the given 2D Boolean array Evening[], the FALSE and TRUE meanings, the four-seat booking limit and the five requirements hidden in the bullet list.

02 · Construct

Build the program in order: count the booked seats with nested loops and output the total, input and validate the number of seats required with a re-ask loop, then check availability before changing any seat.

03 · Complete

Allocate seats in row-major order — a request can cross a row boundary — output the row and seat number for every seat booked, and report the seats-left message or “House full” when the request cannot be met.

!

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 Boolean meanings, the four-seat limit and the rule that seats are allocated in order all shape the structure of your solution.

Question 10 · 15 marks
Cambridge IGCSE Computer Science · 0478/21 · Question 10

Drama students put on a performance of a play for one evening. Seats in a small theatre can be booked for this performance.

The theatre has 10 rows of 20 seats. The status of the seat bookings for the evening is held in the two-dimensional (2D) Boolean array Evening[].

Each element contains FALSE if the seat is available and TRUE if the seat is booked.

Up to and including four seats can be booked at one time. Seats are allocated in order from those available. A row or seat number cannot be requested.

The array Evening[] has already been set up and some data stored.

Write a program that meets the following requirements:

  • counts and outputs the number of seats already booked for the evening
  • allows the user to input the number of seats required
  • validates the input
  • checks if enough seats are available:
    • if they are available
      • changes the status of the seats
      • outputs the row number and seat number for each seat booked
    • if they are not available:
      • outputs a message giving the number of seats left or ‘House full’ if the theatre is fully booked.

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 do not need to initialise the data in the array Evening[]

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

Find the number of seats available for the performance and output it — searching the 10 × 20 Boolean array Evening[] with nested iteration, counting the TRUE cells into SeatCounter.

R2

Allow the user to input the number of seats required — input with a suitable message; up to and including four seats can be booked at one time.

R2

Validate the input — iteration and selection that re-ask while the value is below 1, above 4 or not a whole number.

R3

Check if enough seats are available; if they are, change the status of the seats and output the row number and seat number for each seat booked — selection, assignment and output.

R3

If they are not available, output a message giving the number of seats left or “House full” if the theatre is fully booked — selection and output with appropriate messages.

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.