Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3.
Name the data structures and describe one of them fully. Example answer: an array named FirstName to store the first names of the members, such as James, and a variable to input whether or not they wish to volunteer.
Uses an array [1]
Uses a variable (or a constant) [1]
Gives a name, for example FirstName [1]
Gives sample data, for example James [1]
Gives the use, for example to store the first names of the members [1]
Describing a second array with its name, sample data and use is also credited, up to the 5 marks.
Explain how the total could be kept. Any three of these:
Add a new variable (or array) to hold the total money collected, or the number of members who have paid [1]
Initialise it to 0 at the start of the program [1]
Use an IF statement to check whether the new member has paid the $75 fee, and if so add 75 to the running total [1]
Adding 1 to a count of paid members, and multiplying by 75 to give the total paid, is also credited.
Describe the checks and say what each is for. Any three of these:
A presence check to make sure something has been entered for "Do you want to work as a volunteer?" [1]
A check that the input matches the expected answer, for example yes or no [1]
If the input is not valid, an error message is output and a new input is requested [1]
A type check that the data is the right type, for example an integer if 1 or 0 is required, is also credited. Only naming checks scores a maximum of two.
Ask for the name and message, show them, let the sponsor correct them, then store them and show the fee.
ArrayIndex ← 0
Check ← "N"
WHILE Check <> "Y" DO
OUTPUT "Enter your name"
INPUT Name
OUTPUT "Enter the message you would like on your brass plaque"
INPUT Message
OUTPUT "Your name is ", Name, " and your message is ", Message
OUTPUT "Is this correct? (Y or N)"
INPUT Check
IF Check <> "Y"
THEN
OUTPUT "The data entered is incorrect, please re-enter"
ENDIF
ENDWHILE
PlankName[ArrayIndex] ← Name
PlankMessage[ArrayIndex] ← Message
ArrayIndex ← ArrayIndex + 1
OUTPUT "The fee for this service is $200"Any five of these points score one each:
Name and message input, both with suitable prompts [1]
The input is output for the sponsor to confirm [1]
A method for the sponsor to confirm the details are correct [1]
A method to enter the message again if there are errors [1]
The name and message are stored in arrays [1]
Also credited: the array index increased for the next sponsor, and the $200 fee shown or charged.
Explain each step. Any four of these:
A menu is shown so the user can choose which list to see [1]
The user inputs the number or code of their choice from the menu [1]
The input is validated: if it does not match an option, an error message is shown and it is input again [1]
If it matches, IF statements or a CASE statement compare the input with the options [1]
Also credited: a loop outputs the matching first-name and last-name arrays, and an empty list is spotted and dealt with.
▶ Topic lesson
A lesson on this topic · by Craig'n'Dave. 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.