9618/21/M/J/21 question 1: worked solution (May/June 2021, paper 21)

Show as 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. Q1 9618/21/M/J/21 original Q1 Structured · 12 marks Worked solution (a) Pick a meaningful name and the data type that matches each example value: Example value Variable name Data type "Wong" MemberName STRING FALSE FamilyMember BOOLEAN 19/02/1983 StartDate DATE 1345 Points INTEGER Name and type correct for the name row ( STRING ) [1] Name and type correct for the FALSE row ( BOOLEAN ) [1] Name and type correct for the date row ( DATE ) [1] Name and type correct for the points row ( INTEGER ) [1] Any sensible, meaningful variable names score. (b) Check each statement for a wrong use of an operator or function: Statement Error Result ← 2 & 4 & joins strings. For numbers use an arithmetic operator, or make 2 and 4 into strings SubString ← MID("pseudocode", 4, 1) NO ERROR IF x = 3 OR 4 THEN 4 is not a Boolean value, so the condition is wrong. It should be x = 3 OR x = 4 Result ← Status AND INT(x/2) INT(x/2) gives a number, not a Boolean value, so AND cannot be used Message ← "Done" + LENGTH(MyString) You cannot add a string to a number: "Done" is not a number Row 1 error described [1] Row 2: write NO ERROR [1] Row 3 error described [1] Row 4 error described [1] Row 5 error described [1] (c) Write: Structure = record . Write: a record can hold different data types [1] Write: stored under one identifier (one record per student) [1] Structure named as a record [1] Alternative: two 1D arrays, one STRING and one INTEGER, where the same index links a name to its score. This scores the same three marks. KEY IDEA A record holds items of different data types under one name, and each operator or function must be used on the right data type. TOTAL 12 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Papersdock. Tap the picture to open it on YouTube.