2210/23/O/N/23 question 4: worked solution (October/November 2023, paper 23)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.5 Validation and verification checks Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 4 of 8. Q28 2210/23/O/N/23 original Q4 Structured · 9 marks Worked solution (a) Write: Type check (whole number / integer) [1] Range check (from 1 to 6) [1] (b) Use a loop that keeps asking until the number passes both checks. A whole number is one that equals itself when rounded. WHILE Seats < 1 OR Seats > 6 OR Seats <> ROUND(Seats, 0) DO OUTPUT "Please enter a valid number of seats " INPUT Seats ENDWHILE Loop used to repeat the check [1] Check for a whole number [1] Check for greater than or equal to 1 [1] Check for less than or equal to 6 [1] Error message and the value input again [1] (c) Write one item of test data and why: Test data: 7 [1] Reason: it is abnormal data (outside the range), to show it is rejected [1] Other correct pairs score, for example 3 as normal data, or 1 or 6 as extreme data, or 2.5 or a letter as abnormal data. KEY IDEA A validation loop tests every rule in one condition and asks again until the input is valid. TOTAL 9 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by O/Alevel CS by Wasiq. Tap the picture to open it on YouTube.