Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 1 of 4.
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]
Write: a 1D array of records (one record for each customer). One mark for array, one for records.
Array [1]
Records [1]
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.
▶ 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.