Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738
Question 28
Medium

An algorithm is used to calculate the delivery charge of a heavy-duty drone courier based on the weight of a package in kilograms.

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

Complete the table below to show the final output displayed by line 29 of the algorithm for each given input.

InputOutput
16
3
8
[3]

Algorithms Questions

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