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

Q4 · 9618/21/M/J/23 Q3

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

Q49618/21/M/J/23original Q3Structured · 11 marks
Question 3 from 9618/21/M/J/23

Worked solution

(a)(i)

Write the structure: record [1]

Advantage: a record holds all the data about one customer [1]

...data of different types (string, integer, date) [1]

...all held under a single identifier [1]

(a)(ii)

Write: a 1D array of records (one record for each customer). One mark for array, one for records.

Array [1]

Records [1]

(b)

Break the algorithm into five steps:

1 Input the amount spent (stored in a numeric variable); constants or variables can hold the thresholds 10 and 100 [1]

2 Work out which band the amount falls into (compare with 10 and 100) [1]

3 Work out the whole number of dollars in the amount (round down, ignoring the cents) [1]

4 Multiply the whole dollars by 5, 7 or 10, depending on the band [1]

5 Output the number of points [1]

Other correct orders and wording also score if each point is covered.

KEY IDEAUse a record for mixed-type data about one item, and an array of records for many items.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/21/M/J/23 question 3
VIDEO
▶ Starts at Q3 (18:04)

Starts at Q3 (18:04) · 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.