9618/32/O/N/22 question 4: worked solution (October/November 2022, paper 32)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3. Q6 9618/32/O/N/22 original Q4 Structured · 10 marks 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 IDEA Declare the enumerated type first, then use it as a field type inside the composite type. TOTAL 10 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.