Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
Describe the steps in words, with no pseudocode. Any five of these six points (only five carry a mark):
Open the file Sales.txt in read mode, and close it at the end [1]
Read a line from the file [1]
Convert the line (a string) to a number [1]
If the number is greater than 500, output the week number [1]
Add 1 to the week number each time a line is read (it must be set to 1 first) [1]
Repeat from reading a line 52 times, or until the end of the file (also accepted, but any five only)
Any three of these five points (only three carry a mark):
The walkthrough goes through the program one line or statement at a time (a dry run, or single-stepping), or the code is checked by other people (peer review) [1]
A trace table is created [1]
Test data is drawn up with the expected outputs (normal, boundary and abnormal data) [1]
An error shows when a variable or output has an unexpected value (also accepted, but any three only)
Faults in the logic can be found, for example the program takes an unexpected path (also accepted, but any three only)
▶ 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.