IGCSE cs 0478 2023 Nov 21 10
IGCSE cs 0478 2023 Nov 21 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.
Python版初始化代码,练习的时候使用如下的代码
图解

Python版答案
Last updated
Was this helpful?