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

Show as 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. Q58 9618/21/M/J/25 original Q1 Structured · 12 marks Worked solution (a) Choose a clear name and the type that fits the example value: Example value Explanation Variable name Data type "Fruit" a category of stock that is sold in the shop Category STRING 20/02/2025 when an item was sold DateSold DATE 12.67 the cost of an item ItemCost REAL TRUE to indicate if an item is in stock InStock BOOLEAN Category, STRING [1] DateSold, DATE [1] ItemCost (or Price), REAL [1] InStock, BOOLEAN [1] (b) Look for an arrow (assignment), an IF or CASE (selection) and a loop (iteration): Pseudocode extract Assignment Selection Iteration Result ← CalculateTotal() ✓ WHILE IsClosed ✓ REPEAT INPUT Value UNTIL Sales [4] > Value ✓ ✓ IF Sales[Current] <= 150 THEN ... ENDIF ✓ ✓ CASE OF Option ✓ Row 1 correct [1] Row 2 correct [1] Row 3 correct (INPUT stores a value, so assignment as well as iteration) [1] Row 4 correct [1] Row 5 correct [1] (c) Write any three of these: Decomposition means breaking a problem down into smaller sub-problems [1] so that each part of how the stock control is managed can be understood in more detail [1] This leads to a program designed as a series of modules (procedures and functions), for example separate stock control modules [1] It makes the program easier to test and debug (also scores, but 3 marks is the maximum) Maximum 3 marks, and maximum 2 if stock control is not mentioned. KEY IDEA Name variables clearly with the right data type, and break big problems into small modules. TOTAL 12 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Sir Sikandar Raza. Tap the picture to open it on YouTube.