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

Q5 · 9618/22/O/N/23 Q1

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

Q59618/22/O/N/23original Q1Structured · 11 marks
Question 1 from 9618/22/O/N/23

Worked solution

(a)

Choose a meaningful name for each item and the data type that matches its example value.

Example valueExplanationVariable nameData type
"Mr Khan"The name of the customerCustomerNameSTRING
3The number of items in the orderNumItemsINTEGER
TRUETo indicate whether this is a new customerNewCustomerBOOLEAN
15.75The deposit paid by the customerDepositREAL

Row 1 has a suitable name and STRING [1]

Row 2 has a suitable name and INTEGER [1]

Row 3 has a suitable name and BOOLEAN [1]

Row 4 has a suitable name and REAL [1]

(b)

Work out each expression using the example values.

ExpressionEvaluates to
(Total * DepRate) + 1.5249.50
RIGHT(Description, 7)"(small)"
(LENGTH(Description) - 8) > 16TRUE
NUM_TO_STR(INT(DepRate * 10)) & '%'"20%"

(124.00 × 2.00) + 1.5 = 249.50 [1]

The last 7 characters are "(small)" [1]

The description has 30 characters, 30 - 8 = 22, and 22 > 16 is TRUE [1]

2.00 × 10 = 20, as a string with % it is "20%" [1]

(c)

Use a record to hold the different data types, then an array of those records.

Declare a record (composite) type containing all the data items needed for one order, even though they are of different data types [1]

Declare an array of that record type [1]

Each element of the array holds the data for one customer order [1]

KEY IDEAA record holds mixed data types for one item and an array of records holds many of them.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/22/O/N/23 question 1
VIDEO
▶ Starts at Q1 (0:25)

Starts at Q1 (0:25) · by Pseudocode Pro. 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.