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

Q6 · 9618/32/O/N/22 Q4

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

Q69618/32/O/N/22original Q4Structured · 10 marks
Question 4 from 9618/32/O/N/22

Worked solution

(a)

TYPE Aircraft = (C300, C350, D242, E757, X380)

TYPE Aircraft = [1]

(C300, C350, D242, E757, X380) [1]

(b)

TYPE Flight
    DECLARE FlightNumber : STRING
    DECLARE Destination : STRING
    DECLARE DepartureDate : DATE
    DECLARE AircraftType : Aircraft
ENDTYPE

TYPE Flight and ENDTYPE correct [1]

FlightNumber (letters and numbers, so STRING) and Destination declared as STRING [1]

Departure date declared as DATE [1]

Aircraft type declared using the type Aircraft from part (a) [1]

(c)(i)

DECLARE Flight1 : Flight

Variable declared with the type Flight [1]

(c)(ii)

Flight1.FlightNumber ← "XA782"
Flight1.Destination ← "Cambridge"
Flight1.DepartureDate ← 12/12/2022
Flight1.AircraftType ← C350

Both strings assigned in quotes [1]

Date assigned [1]

Enumerated value C350 assigned with no quotes [1]

KEY IDEADeclare the enumerated type first, then use it as a field type inside the composite type.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/32/O/N/22 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by qiphyedu. 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.