Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 55

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.

RequirementInput: ageInput: day
A condition generating 'Standard weekend: £15'
A condition generating 'Age category error'
A condition generating 'Junior day error'
[3]
Markscheme

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

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.

Question bank