Cambridge AS Level Computer Science 9618 · 10.1 Data Types and Records

Q8 · 9618/21/O/N/25 Q3

Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 1 of 4.

Q89618/21/O/N/25original Q3Structured · 9 marks
Question 3 from 9618/21/O/N/25

Worked solution

(a)(i)

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
ENDTYPE

TYPE 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]

(a)(ii)

DECLARE Rental : ARRAY[1:500] OF RentalRecord

An array with 500 elements, for example ARRAY[1:500] [1]

Of type RentalRecord [1]

(b)

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]

KEY IDEAA record groups items of different types; an array of records lets you store, index and loop through many such records.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/21/O/N/25 question 3
VIDEO
▶ 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.