Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738
Question 21
Medium

An algorithm is designed to calculate the shipping charge for an automated drone delivery service based on the weight of a parcel in kilograms, as shown below:

10 SEND "Welcome to DroneDrop Delivery" TO DISPLAY
11 SEND "Enter package weight in kg:" TO DISPLAY
12 RECEIVE weight FROM (INTEGER) KEYBOARD
13 SEND "Processing rate for " & weight & " kg" TO DISPLAY
14
15 IF (weight > 15) THEN
16     SET charge TO 45 + (8 * (weight - 15))
17 ELSE
18     IF (weight > 8) THEN
19         SET charge TO 45
20     ELSE
21         IF (weight > 3) THEN
22             SET charge TO 25
23         ELSE
24             SET charge TO 12
25         END IF
26     END IF
27 END IF
28
29 SEND "Total shipping charge: £" & charge TO DISPLAY

The algorithm needs to be thoroughly tested.

Complete the table to give suitable input test data to meet the requirements.

RequirementInput Test Data
Output charge = 25
An output that is not correct (logical error)
[2]

Algorithms Questions

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