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

Show as plain text

Cambridge AS Level Computer Science 9618 · 12.3 Program Testing and Maintenance Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3. Q42 9618/23/O/N/22 original Q6 Structured · 11 marks Worked solution (a) Test every outcome and the boundaries. Reject is 3 g or more beyond a limit, Recheck is within 2 g of a limit, Accept is anything further inside. Using Min = 290 and Max = 315: Test number Component weight Min Max Expected return value 1 300 290 315 'A' 2 320 290 315 'R' 3 317 290 315 'C' 4 288 290 315 'C' 5 286 290 315 'R' Row 1 correct [1] Row 2 correct [1] Row 3 correct [1] Row 4 correct [1] Row 5 correct [1] Any weights in the same ranges also score, for example any value above 317 for 'R' and below 288 for 'R'. (b) Start with the Recheck result, then change it to Reject or Accept when those tests pass: FUNCTION Status(Actual, Min, Max : INTEGER) RETURNS CHAR DECLARE Result : CHAR Result ← 'C' IF Actual > Max + 2 OR Actual < Min - 2 THEN Result ← 'R' ENDIF IF Actual < Max - 2 AND Actual > Min + 2 THEN Result ← 'A' ENDIF RETURN Result ENDFUNCTION Function heading and ending, with the parameters [1] A local variable declared for the result [1] Check for Reject [1] Check for Accept [1] Check for Recheck (or just use it as the default result) [1] Result returned after a reasonable attempt [1] KEY IDEA Test each outcome and each boundary, and in the code check the limits with the right greater-than and less-than signs. TOTAL 11 marks Official mark scheme VIDEO ▶ Starts at Q6 (11:58) Starts at Q6 (11:58) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.