9618/22/M/J/22 question 5: worked solution (May/June 2022, paper 22)

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. Q36 9618/22/M/J/22 original Q5 Structured · 10 marks Worked solution (a) The loop is WHILE … ENDWHILE, so the test is at the start. Type: pre-condition loop (a WHILE loop) [1] Condition: the loop ends when the input value (ThisNum) is equal to zero [1] (b) Run each input through the loop. Only write the values that change. ThisNum ThisChar CountA CountB Flag OUTPUT 0 10 TRUE 12 '1' 1 24 '2' 57 '5' "Ignored" 43 '4' 9 FALSE 56 '5' 4 22 '2' TRUE "Flip" 31 '3' 8 32 '3' 7 47 '4' 6 FALSE 99 '9' TRUE "Flip" 0 4 Columns ThisNum and ThisChar correct [1] Rows for 12, 24 and 57 correct (CountA 1, then "Ignored") [1] Rows for 43 and 56 correct (CountB 9, Flag FALSE, CountA 4) [1] Rows for 22 and 31 correct (Flag TRUE, "Flip", CountB 8) [1] Rows for 32 and 47 correct (CountB 7, then 6, Flag FALSE) [1] Rows for 99 and 0 correct (Flag TRUE, "Flip", final OUTPUT 4) [1] (c) Integration testing means: Modules that have already been tested individually [1] are combined into one (sub) program which is then tested as a whole [1] KEY IDEA Dry run one input at a time, updating only the variables that change, and remember that a WHILE loop tests its condition before each pass. TOTAL 10 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Awab Aqib. Tap the picture to open it on YouTube.