Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
Look at the order of the two decisions.
The decision boxes are in the wrong order: a value such as 3000 fails the first test (> 4000) and goes straight to RETURN, so it is never tested against 2000 [1]
Swap them round:
Swap the two decision boxes: first test >= 2000, and then test > 4000 for those values [1]
Write any one value: 2000 (or 4000, 10, 100) [1]
Any two points:
A constant cannot be changed while the program runs, so it cannot be different in two places [1]
The value is only written once, so a change needs one edit, and the meaningful name makes the program easier to understand [1]
Library routines are already tried and tested, so they are free of errors (and give code that is hard to write yourself) [1]
Two other types of error:
Syntax error [1]
The rules of the programming language were not followed [1]
Run-time error [1]
The program tries an illegal operation, such as dividing by zero, while it runs [1]
▶ Whole paper
Video solution of the whole paper · by Sir Sikandar Raza. 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.