Your ticket is valid and you're 15. Why might the entry program turn you away?
You're fifteen and you've got a valid ticket to a youth event in Leeds. The rules say you can go in, but the program prints Refuse. Can you spot what went wrong and show your reasoning the way the exam question asks?
You already know the pattern: input, process, output. Here, the inputs are age in whole years and yes or no for ticket validity. The program checks that the age is twelve to fifteen inclusive and that the ticket answer is yes. It prints Admit if both checks pass, and Refuse otherwise.
For trace, run the given code by hand and record the values or output asked for. For explain, give the reason something happens. For write program code, produce instructions in your selected programming language that meet the requirements.
Use the entry rules to explain why someone aged eleven with a valid ticket is refused. You already know the result. Which response links it to the rule that both checks must pass? Pick one.
Here’s a Python solution that includes both endpoints. Read the age as a whole number, then read the ticket answer as lowercase yes or no. Store whether the age is in range. If that result is true and the ticket answer is yes, print Admit. Otherwise, print Refuse.
First record age fifteen and ticket yes. The age check includes fifteen, so record true for age okay. Comparing the ticket answer with yes also gives true. With and, both checks must be true, so the condition passes. Record Admit as the output.
Now trace the same code for someone aged twelve who enters no for their ticket. Work out the age check first, then the printed output. Pick the pair you would record.
Look at what happens if you use a strict less-than sign at the top of the range. Fifteen is not less than fifteen, so a fifteen-year-old gets refused even with a valid ticket. Less than or equal to keeps the endpoint in.
Set the expected outputs from the rules. With a valid ticket, eleven is refused, twelve and fifteen are admitted, and sixteen is refused. Then keep age twelve and change the ticket answer to no: expect Refuse. The Python code matches all five, including the case where only the ticket check fails.
AQA’s written Paper One is two hours and worth ninety marks. If it says trace the entry code, record the values or output requested. If it says explain, give the reason for the result. If it says write program code, use your selected supported language rather than pseudocode.