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

Q87 · 2210/21/M/J/21 Q4

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

Q872210/21/M/J/21original Q4Structured · 9 marks
Question 4 from 2210/21/M/J/21

Worked solution

(a)

Describe the steps in order. Write three of these:

The marks input are stored in the array Score[] [1]

Each mark is checked against boundaries (70, 60, 50, 40, 30) and a matching grade is stored in the array Grade[] at the same index as the mark [1]

This is repeated until 30 marks have been input [1]

(b)

Use a loop to go through each element and output both arrays with a message.

FOR Count ← 0 TO 29
    OUTPUT "Student: ", Count, " Mark: ", Score[Count], " Grade: ", Grade[Count]
NEXT Count

Correct loop (including a counter if it is not a FOR loop) [1]

Score[] and Grade[] both output correctly [1]

Suitable messages or text in the output [1]

A WHILE or REPEAT loop with its own counter also scores.

(c)

Write three of these:

Add an input so the teacher can enter the class size [1]

Store it in a variable and use it as the end condition of the loop (UNTIL Count = ClassSize) [1]

Make sure the arrays are big enough for the largest class [1]

KEY IDEAUse a variable for the class size and loop to it instead of a fixed number like 30.
TOTAL 9 marks

Official mark scheme

Mark scheme for 2210/21/M/J/21 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.