Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.
Many answers are accepted if they are meaningful. Example answers:
Constant: AdultCostOneDay [1]
Value: 20.00 [1]
Use: stores the cost of an adult ticket for one day [1]
Many answers are accepted if they are meaningful. Example answers:
Variable: NumberOfTickets (or NumberOfAdultTickets) [1]
Data type: integer [1]
Use: input the number of tickets (or adult tickets) purchased [1]
Any three of these:
Use an array or variables (or a lookup, or input today's date) to hold today's date or the days of the week [1]
Use a loop (FOR, REPEAT or WHILE) [1]
… to output today's date and the following 6 or 7 days with a suitable message [1]
Another way also scores: an array holding all the days of the week (or the next seven days or dates), and an attempt to output the available days with suitable messages.
Any two of these:
A method to allocate a new number, for example start a counter variable, or select a random number [1]
How it ensures uniqueness, for example every booking number is one larger than the last, or the existing bookings are checked so the number has not been used before [1]
Total up the tickets (checking children against adults), then the attractions (checking against the number of people).
TotalCost ← 0
TotalPeople ← 0
FOR Type ← 1 TO 3
REPEAT
Valid ← TRUE
OUTPUT "How many ", TicketDescription[Type], " tickets?"
INPUT NumberOfTickets[Type]
IF Type = 2 AND NumberOfTickets[2] > 2 * NumberOfTickets[1]
THEN
Valid ← FALSE
OUTPUT "Too many children"
ENDIF
UNTIL NumberOfTickets[Type] >= 0 AND Valid = TRUE
TotalCost ← TotalCost + TicketPrice[Type] * NumberOfTickets[Type]
TotalPeople ← TotalPeople + NumberOfTickets[Type]
NEXT Type
REPEAT
OUTPUT "How many people want the lion feeding?"
INPUT LionNumber
UNTIL LionNumber <= TotalPeople
TotalCost ← TotalCost + LionNumber * LionPrice
OUTPUT "Total cost: ", TotalCostAny six of these points score one each:
A running total for the cost is set to 0 [1]
Number of tickets input with a prompt [1]
Attempt to identify the type of ticket [1]
Cost of the tickets added to the running total [1]
Several types of ticket can be booked [1]
Attempt to check the number of children is no more than twice the number of adults [1]
Also credited: attractions identified, the number of attractions input with a prompt, checked to be no more than the number of tickets, and their cost added to the total.
Explain each step. Any three of these:
Use selection (or another method) to find bookings with 2 or more adults and/or seniors and 2 (3 is also accepted) or more children [1]
Calculate the new price for the booking including family ticket(s) [1]
Use a condition to compare the family ticket price with the price of the ordinary or group tickets [1]
Identifying the best value (lowest cost) is also credited.
▶ Whole paper
Video solution of the whole paper · by Zafar Ali Khan (ZAK). 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.