An algorithm is used to calculate the ticket price for a theme park based on the visitor's age and the day of the week (where 1 represents Monday and 7 represents Sunday).
2 IF (age < 0) THEN
3 SEND ("Invalid age") TO DISPLAY
4 ELSE
5 IF (age >= 18) AND (age <= 65) THEN
6 IF (day >= 1) AND (day <= 5) THEN
7 SEND ("Standard weekday: £12") TO DISPLAY
8 ELSE
9 IF (day = 6) OR (day = 7) THEN
10 SEND ("Standard weekend: £15") TO DISPLAY
11 ELSE
12 SEND ("Standard day error") TO DISPLAY
13 END IF
14 END IF
15 ELSE
16 IF (age >= 0) AND (age < 18) THEN
17 IF (day >= 1) AND (day <= 5) THEN
18 SEND ("Junior weekday: £6") TO DISPLAY
19 ELSE
20 IF (day = 6) OR (day = 7) THEN
21 SEND ("Junior weekend: £8") TO DISPLAY
22 ELSE
23 SEND ("Junior day error") TO DISPLAY
24 END IF
25 END IF
26 ELSE
27 SEND ("Age category error") TO DISPLAY
28 END IF
29 END IF
30 END IF
The algorithm needs to be tested.
Construct test data to meet the requirements set out in the table below.
| Requirement | Input: age | Input: day |
|---|---|---|
| A condition generating 'Standard weekend: £15' | ||
| A condition generating 'Age category error' | ||
| A condition generating 'Junior day error' |
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.