9618/21/M/J/24 question 1: worked solution (May/June 2024, paper 21)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3. Q19 9618/21/M/J/24 original Q1 Structured · 11 marks Worked solution (a) Match each variable to the kind of value stored: Assignment statement Data type A ← LEFT(MyName, 1) CHAR (or STRING) B ← Total * 2 INTEGER (or REAL) C ← INT(ItemCost) / 3 REAL D ← "Odd OR Even" STRING A: CHAR or STRING [1] B: INTEGER or REAL [1] C: REAL (division) [1] D: STRING [1] (b) Use Sorted = False, Tries = 9, ID = "ZGAC001": Expression Evaluates to Tries < 10 AND NOT Sorted TRUE Tries MOD 4 1 TO_LOWER(MID(ID, 3, 1)) "a" LENGTH(ID & "xx") >= Tries TRUE 9 < 10 is TRUE and NOT FALSE is TRUE, so TRUE [1] 9 ÷ 4 = 2 remainder 1 [1] The 3rd character of ID is "A", in lower case "a" [1] ID & "xx" has 9 characters and 9 >= 9, so TRUE [1] (c)(i) Write: the names do not show what each variable is used for (they are not meaningful). [1] (c)(ii) Write: the program is harder to understand , debug or maintain. [1] (c)(iii) Write any one of: indentation or white space; capital letters for keywords; comments ; modular programming; local variables. [1] KEY IDEA Use meaningful names so the program is easy to read, debug and maintain. 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.