Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 1 of 4.
Declare each item with a name and a data type inside TYPE ... ENDTYPE.
TYPE RentalRecord
DECLARE RentalID : STRING
DECLARE CarID : INTEGER
DECLARE DisCode : CHAR
DECLARE Start : DATE
DECLARE Duration : INTEGER
DECLARE Completed : BOOLEAN
ENDTYPETYPE RentalRecord and ENDTYPE [1]
RentalID as STRING and CarID as INTEGER [1]
DisCode as CHAR and Start as DATE [1]
Duration as INTEGER and Completed as BOOLEAN [1]
DECLARE Rental : ARRAY[1:500] OF RentalRecord
An array with 500 elements, for example ARRAY[1:500] [1]
Of type RentalRecord [1]
Any three of these:
Items of different data types are held for each rental under a single identifier [1]
The rentals can be reached in a loop, or one rental directly using an index [1]
The program is simpler: less code, easier to understand, test and maintain [1]
▶ Whole paper
Video solution of the whole paper · by CSFeedbySirNisarAli. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.