Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 4 of 8.
Match one check to each rule. Any three of these:
Range check: the value must be greater than 0 and less than 1000 [1]
Presence check: a value must be entered, so the program cannot go on with an empty input [1]
Type check (character check): make sure a number is entered, not letters [1]
A length check also scores: no more than 3 digits are entered.
Write: it is a verification check, to make sure the data has not changed or been mistyped when it was entered [1]
Use a loop that asks for the value twice and repeats until both inputs match.
REPEAT
OUTPUT "Please enter measurement "
INPUT Measurement
OUTPUT "Please re-enter measurement "
INPUT MeasurementCheck
UNTIL Measurement = MeasurementCheckIteration used (REPEAT ... UNTIL or any working loop) [1]
Two inputs, one stored in the variable Measurement [1]
The loop ends only when the two inputs are compared and are the same [1]
▶ Whole paper
Video solution of the whole paper · by CS BY AQIB KHAN. 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.