Cambridge AS Level Computer Science 9618 · 11.2 Constructs

Q53 · 9618/23/M/J/24 Q6

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

Q539618/23/M/J/24original Q6Structured · 9 marks
Question 6 from 9618/23/M/J/24

Worked solution

(a)

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)
ENDPROCEDURE

Procedure 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.

(b)(i)

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]

(b)(ii)

The progress display shows the progress of the task more accurately. [1]

KEY IDEATurn a percentage into a step number with DIV, then join the parts of the file name as a string.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/23/M/J/24 question 6
VIDEO
▶ 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.