Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types

Q16 · 9618/31/M/J/25 Q1

Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3.

Q169618/31/M/J/25original Q1Structured · 6 marks
Question 1 from 9618/31/M/J/25

Worked solution

(a)

An enumerated type lists every allowed value in brackets after TYPE.

TYPE Vehicle = (M100, M230, T101, T102, T120, T150)

TYPE Vehicle = [1]

All six values in brackets [1]

(b)

Use STRING for text, including codes and telephone numbers (a phone number is not used in sums, and may start with 0). Use DATE for the date and the enumerated type Vehicle for the taxi.

TYPE Booking
    DECLARE BookingNumber : STRING
    DECLARE Destination : STRING
    DECLARE ClientName : STRING
    DECLARE ClientTelephone : STRING
    DECLARE DateOfDeparture : DATE
    DECLARE PickupAddress : STRING
    DECLARE TaxiUsed : Vehicle
ENDTYPE

TYPE Booking and ENDTYPE correct [1]

DECLARE used correctly for every field [1]

Any four fields with correct types [1]

The remaining fields with correct types [1]

KEY IDEAPick the most suitable type for each field: STRING for codes and phone numbers, DATE for dates and an enumerated type for a fixed list.
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/31/M/J/25 question 1
VIDEO
▶ Topic lesson

A lesson on this topic · by ZAINEMATICS. 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.