Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 51

An algorithm is used to calculate the hire fee for a workspace based on the booking duration hours and the member's tier level tier (where 1 represents Bronze, 2 represents Silver, and 3 represents Gold).

2 IF (hours <= 0) THEN
3     SEND ("Invalid duration") TO DISPLAY
4 ELSE
5     IF (hours > 2) AND (hours <= 8) THEN
6         IF (tier = 1) OR (tier = 2) THEN
7             SEND ("Standard booking: £15") TO DISPLAY
8         ELSE
9             IF (tier = 3) THEN
10                SEND ("Premium booking: £25") TO DISPLAY
11            ELSE
12                SEND ("Standard tier error") TO DISPLAY
13            END IF
14        END IF
15    ELSE
16        IF (hours > 0) AND (hours <= 2) THEN
17            IF (tier = 1) OR (tier = 2) THEN
18                SEND ("Short booking: £5") TO DISPLAY
19            ELSE
20                IF (tier = 3) THEN
21                    SEND ("VIP short booking: £10") TO DISPLAY
22                ELSE
23                    SEND ("Short tier error") TO DISPLAY
24                END IF
25            END IF
26        ELSE
27            SEND ("Duration 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: hoursInput: tier
A condition generating 'Premium booking: £25'
A condition generating 'Duration category error'
A condition generating 'Short tier 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