Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3.
Each step covers 10 percent, so the step number is Percent DIV 10 plus 1. Then build the file name and call Display():
PROCEDURE Progress(Percent : INTEGER, Root : STRING)
DECLARE StepValue : INTEGER
DECLARE Filename : STRING
StepValue ← (Percent DIV 10) + 1
Filename ← Root & "-" & NUM_TO_STR(StepValue) & ".bmp"
CALL Display(Filename)
ENDPROCEDUREProcedure heading, parameters and ending [1]
Percent DIV 10 (or INT(Percent / 10)) used to get a whole number [1]
1 added to get the correct file number (100 gives 11) [1]
NUM_TO_STR() used to turn the number into a string [1]
Root, a hyphen, the number and ".bmp" joined together [1]
Display() called with the file name [1]
A CASE or IF solution with one branch for each step also scores.
FUNCTION Progress2(Percent, Steps : INTEGER, Root : STRING) RETURNS STRING
Keyword FUNCTION, name Progress2 and three parameters of the correct types [1]
Keyword RETURNS and the type STRING [1]
The progress display shows the progress of the task more accurately. [1]
▶ Starts at Q6 (48:46)
Starts at Q6 (48:46) · by Pseudocode Pro. 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.