Cambridge O Level Computer Science 2210 · 7.9 Writing and amending algorithms

Q93 · 2210/21/M/J/22 Q4

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 8 of 8.

Q932210/21/M/J/22original Q4Structured · 10 marks
Question 4 from 2210/21/M/J/22

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 IDEAIn 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

Mark scheme for 2210/21/M/J/22 question 4
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.