9618/22/O/N/23 question 1: worked solution (October/November 2023, paper 22)

Show as plain text

Cambridge AS Level Computer Science 9618 · 10.1 Data Types and Records Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 1 of 4. Q5 9618/22/O/N/23 original Q1 Structured · 11 marks Worked solution (a) Choose a meaningful name for each item and the data type that matches its example value. Example value Explanation Variable name Data type "Mr Khan" The name of the customer CustomerName STRING 3 The number of items in the order NumItems INTEGER TRUE To indicate whether this is a new customer NewCustomer BOOLEAN 15.75 The deposit paid by the customer Deposit REAL Row 1 has a suitable name and STRING [1] Row 2 has a suitable name and INTEGER [1] Row 3 has a suitable name and BOOLEAN [1] Row 4 has a suitable name and REAL [1] (b) Work out each expression using the example values. Expression Evaluates to (Total * DepRate) + 1.5 249.50 RIGHT(Description, 7) "(small)" (LENGTH(Description) - 8) > 16 TRUE NUM_TO_STR(INT(DepRate * 10)) & '%' "20%" (124.00 × 2.00) + 1.5 = 249.50 [1] The last 7 characters are "(small)" [1] The description has 30 characters, 30 - 8 = 22, and 22 > 16 is TRUE [1] 2.00 × 10 = 20, as a string with % it is "20%" [1] (c) Use a record to hold the different data types, then an array of those records. Declare a record (composite) type containing all the data items needed for one order, even though they are of different data types [1] Declare an array of that record type [1] Each element of the array holds the data for one customer order [1] KEY IDEA A record holds mixed data types for one item and an array of records holds many of them. TOTAL 11 marks Official mark scheme VIDEO ▶ Starts at Q1 (0:25) Starts at Q1 (0:25) · by Pseudocode Pro. Tap the picture to open it on YouTube.