Cambridge AS Level Computer Science 9618 · 12.3 Program Testing and Maintenance

Q52 · 9618/21/M/J/25 Q2

Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.

Q529618/21/M/J/25original Q2Structured · 10 marks
Question 2 from 9618/21/M/J/25

Worked solution

(a)(i)

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]

(a)(ii)

Swap them round:

Swap the two decision boxes: first test >= 2000, and then test > 4000 for those values [1]

(b)(i)

Write any one value: 2000 (or 4000, 10, 100) [1]

(b)(ii)

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]

(b)(iii)

Library routines are already tried and tested, so they are free of errors (and give code that is hard to write yourself) [1]

(c)

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]

KEY IDEAOrder of tests matters in a flowchart, and constants and library routines cut down on mistakes.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/21/M/J/25 question 2
VIDEO
▶ 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.