2210/21/M/J/22 question 4: worked solution (May/June 2022, paper 21)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.9 Writing and amending algorithms Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 8 of 8. Q93 2210/21/M/J/22 original Q4 Structured · 10 marks Worked solution (a) Fill in the blank boxes of the flowchart in order: Input box after Count ← 0: INPUT Score [1] Decision box: IS Score >= 50? [1] Yes side, first box: Pass[PassCount] ← Score [1] No side, first box: Fail[FailCount] ← Score [1] Yes side, second box: PassCount ← PassCount + 1 . No side, second box: FailCount ← FailCount + 1 (both counters increase) [1] Last decision box: IS Count = 60? (Yes goes to END, No goes back to the input) [1] (b) Use a loop that keeps asking while the score is not between 0 and 100. WHILE Score < 0 OR Score > 100 DO OUTPUT "Your entry must be between 0 and 100, inclusive, please try again" INPUT Score ENDWHILE Appropriate conditional loop [1] Correct test for invalid input (below 0 or above 100) [1] Suitable error message [1] Score input again until it is correct [1] Also accepted: REPEAT with an IF inside and UNTIL Score >= 0 AND Score <= 100. KEY IDEA In a flowchart every decision and assignment needs its own box; validation repeats the input while the data is invalid. TOTAL 10 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.