19Medium
0/3

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]
PreviousNext

Computational thinking Questions

  1. GCSE
  2. /Computer Science
  3. /Computational thinking