9618/21/O/N/23 question 1: worked solution (October/November 2023, paper 21)
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. Q47 9618/21/O/N/23 original Q1 Structured · 11 marks Worked solution (a) Work through the CASE clauses in order. Answer Level when ThisValue is 40 "Medium" Check when ThisValue is 36 12 Level when ThisValue is 18 "Low" Elements of Data that may be incremented 11 40 is in 30 TO 40, so "Medium" [1] 36 / 3 = 12 [1] 18 is less than 30 (the first clause), so "Low" [1] Values 30 to 40 give 40 - 30 + 1 = 11 elements [1] (b) Write: the assignment Level ← "Very Low" is never performed [1] Write: because the clauses are checked in order [1] Write: any value below 30 matches the first clause, so the < 20 clause is never reached [1] (c) Write: every possible value is already handled by the other four clauses, so there is no value left for OTHERWISE [1] (d) ThisValue: INTEGER [1] Check: REAL (a division can give a fraction) [1] Level: STRING [1] KEY IDEA A CASE checks clauses from the top, so an earlier broader clause can hide a later one. TOTAL 11 marks Official mark scheme VIDEO ▶ Starts at Q1 (0:23) Starts at Q1 (0:23) · by Pseudocode Pro. Tap the picture to open it on YouTube.