Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 4 of 8.
Write:
Type check (whole number / integer) [1]
Range check (from 1 to 6) [1]
Use a loop that keeps asking until the number passes both checks. A whole number is one that equals itself when rounded.
WHILE Seats < 1 OR Seats > 6 OR Seats <> ROUND(Seats, 0) DO
OUTPUT "Please enter a valid number of seats "
INPUT Seats
ENDWHILELoop used to repeat the check [1]
Check for a whole number [1]
Check for greater than or equal to 1 [1]
Check for less than or equal to 6 [1]
Error message and the value input again [1]
Write one item of test data and why:
Test data: 7 [1]
Reason: it is abnormal data (outside the range), to show it is rejected [1]
Other correct pairs score, for example 3 as normal data, or 1 or 6 as extreme data, or 2.5 or a letter as abnormal data.
▶ Whole paper
Video solution of the whole paper · by O/Alevel CS by Wasiq. 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.