AQA GCSE Computer Science June 2024 Paper 1, Question 5: the wedding cost algorithm
AQA 8525 June 2024 Paper 1, Question 5: work out the output of a nested IF algorithm that prices a wedding for three sets of guests and rooms. Each row worked through, the traps at 50 and 1400, and the algorithm to run.
Question 5 of the AQA GCSE Computer Science Paper 1 sat on 15 May 2024 (8525/1B, the Python paper) gives you a pseudo-code algorithm with nested selection and asks for its output for three pairs of inputs. One mark a row. There is a boundary trap in the first row and another in the second.
We do not copy the exam paper here. Open it beside this page: AQA June 2024 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.
The question in short
The algorithm reads a number of guests and a number of rooms, and sets charge to 25.
- More than 50 guests: the cost is guests times 2.
- Otherwise, 25 guests or more: guests times 4.
- Otherwise: guests times 5.
Then it adds 100 for each room. Last, if the total is less than 1400, it adds the charge of 25. It outputs the total.
Work it through
50 guests, 30 rooms. Is 50 greater than 50? No. Is 50 at least 25? Yes: 50 x 4 = 200. Rooms: 30 x 100 = 3000. Total 3200. Is 3200 less than 1400? No. Output 3200.
20 guests, 10 rooms. Not more than 50, not at least 25: 20 x 5 = 100. Rooms: 1000. Total 1100. Is 1100 less than 1400? Yes: add 25. Output 1125.
500 guests, 5 rooms. More than 50: 500 x 2 = 1000. Rooms: 500. Total 1500. Not less than 1400. Output 1500.
| Guests | Rooms | Output |
|---|---|---|
| 50 | 30 | 3200 |
| 20 | 10 | 1125 |
| 500 | 5 | 1500 |
Where the marks are lost
- Treating 50 as "more than 50". That gives 50 x 2 = 100 and an answer of 3100.
>does not include the number itself. - Forgetting the charge. It only applies under 1400, so it is easy to stop at 1100 in the second row.
- Adding the charge to every row. Check the condition each time.
- Quotation marks round the numbers. The output is a number. AQA penalises quotes once.
Run it
The algorithm as a function, run on the three rows. Add rows of your own to TESTS: try 51 guests, and try to find inputs that total exactly 1400.
The program
from bugbot import *
connect()
TESTS = [[50, 30], [20, 10], [500, 5]]
def wedding(numberOfGuests, numberOfRooms):
charge = 25
if numberOfGuests > 50:
totalCost = numberOfGuests * 2
else:
if numberOfGuests >= 25:
totalCost = numberOfGuests * 4
else:
totalCost = numberOfGuests * 5
totalCost = totalCost + (numberOfRooms * 100)
if totalCost < 1400:
totalCost = totalCost + charge
return totalCost
for guests, rooms in TESTS:
print(guests, "guests,", rooms, "rooms:", wedding(guests, rooms))
Questions
What are the answers to AQA GCSE Computer Science 2024 Paper 1 Question 5?
3200, then 1125, then 1500.
What is nested selection?
An IF statement inside another IF statement. The inner test is only reached when the outer test sends the program down that branch.
What is the difference between > and ≥?
Greater than does not include the value itself, so 50 > 50 is false. Greater than or equal to does, so 50 ≥ 50 is true. Exam questions often use the boundary value as an input to check that you know which is which.
More from this paper
- Question 1: LEN, POSITION, a data type, assignment, and a two line program 6 marks
- Question 2: Follow an IF, ELSEIF chain with NOT, OR, AND and MOD 5 marks
- Question 10: Trace three subroutines that call each other 2 marks
- Question 12.1 to 12.5: A sliding puzzle: move tiles, and read nested loops that find the blank 7 marks
Every AQA 8525 question we have worked · Guide: Trace tables explained
Learn it step by step
- F2.4 Nested selection and match Decisions and loops
- F13.2 Trace tables Exam preparation
This is our own explanation of a published exam question. It is not written or endorsed by AQA, and the question paper and mark scheme remain AQA's copyright. Read them on AQA's site with the links on this page.