Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 8

An algorithm is used to determine the delivery cost of a parcel based on the parcel's weight, weight (in kg), and the destination shipping zone, zone (where zones are represented by integers from 1 to 5).

2 IF (weight <= 0) THEN
3     SEND ("Invalid weight") TO DISPLAY
4 ELSE
5     IF (weight > 20) AND (weight <= 50) THEN
6         IF (zone >= 1) AND (zone <= 3) THEN
7             SEND ("Heavy domestic: £25") TO DISPLAY
8         ELSE
9             IF (zone = 4) OR (zone = 5) THEN
10                SEND ("Heavy remote: £40") TO DISPLAY
11            ELSE
12                SEND ("Heavy zone error") TO DISPLAY
13            END IF
14        END IF
15    ELSE
16        IF (weight > 0) AND (weight <= 20) THEN
17            IF (zone >= 1) AND (zone <= 3) THEN
18                SEND ("Standard domestic: £10") TO DISPLAY
19            ELSE
20                IF (zone = 4) OR (zone = 5) THEN
21                    SEND ("Standard remote: £18") TO DISPLAY
22                ELSE
23                    SEND ("Standard zone error") TO DISPLAY
24                END IF
25            END IF
26        ELSE
27            SEND ("Weight class 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: weightInput: zone
A condition generating 'Heavy remote: £40'
A condition generating 'Weight class error'
A condition generating 'Standard zone 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