Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
Stepwise refinement means improving a design in stages.
It increases the level of detail of the algorithm, breaking the problem into smaller steps [1]
It keeps doing this until each step can be directly written as lines of code [1]
White-box testing tests different paths through the code, so choose data that sends the program down two different branches. Any two of these four tests score:
| Hours worked | Value of sales | Bonus pay |
|---|---|---|
| between 1 and 40 | 2000 or less | 0 |
| above 40 | 2000 or less | 10 |
| between 1 and 40 | above 2000 | 50 |
| above 40 | above 2000 | 100 |
Test one: one correct set of hours, sales and bonus pay from the table [1]
Test two: a different correct set from the table [1]
Stub testing checks the calling parts of the program before every module exists.
Write a simple module (a stub) to replace each unfinished module [1]
Each stub returns an expected value or outputs a message to show it has been called [1]
Write the type of error and its description.
Type of error: logic error [1]
Description: the program does not behave as expected or gives the wrong result because of a fault in the logic of the algorithm [1]
Run-time error (the program performs an illegal operation, for example dividing by zero) with that description also scores, but give only one pair.
▶ Whole paper
Video solution of the whole paper · by Awab Aqib. 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.