9618/23/M/J/24 question 6: worked solution (May/June 2024, paper 23)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 11.2 Constructs Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3. Q53 9618/23/M/J/24 original Q6 Structured · 9 marks 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 IDEA Turn 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 VIDEO ▶ Starts at Q6 (48:46) Starts at Q6 (48:46) · by Pseudocode Pro. Tap the picture to open it on YouTube.