An algorithm is designed to determine cinema ticket rates based on a customer's age, the day of the week (where 1 is Monday and 7 is Sunday), and the hour of the day (in 24-hour format).
1 # Cinema ticket rate calculator
2
3 IF (age < 5) OR (age >= 65) THEN
4 SEND "Discount price" TO DISPLAY
5 ELSE
6 IF (day = 6) OR (day = 7) THEN
7 IF hour >= 17 THEN
8 SEND "Weekend evening price" TO DISPLAY
9 ELSE
10 SEND "Weekend daytime price" TO DISPLAY
11 END IF
12 ELSE
13 IF (hour >= 12) AND (hour <= 16) THEN
14 SEND "Saver afternoon price" TO DISPLAY
15 ELSE
16 SEND "Standard weekday price" TO DISPLAY
17 END IF
18 END IF
19 END IF
Complete the table to show the output of the algorithm for each set of inputs.
| Inputs | Output |
|---|---|
age = 72, day = 6, hour = 19 | |
age = 30, day = 6, hour = 15 | |
age = 35, day = 2, hour = 14 |
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.