Skip to content

Course home

Sign up

Computational thinking

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
Question 90

A shipping program, ShipClassify, categorizes packages according to weight limits in grams.

Here is the pseudo-code for an algorithm that determines the delivery category of a package.

1 SET weightThresholds TO [100, 250, 500, 1000]
2 SET shippingCategory TO ["Standard", "Express", "Priority", "Overnight", "Heavy Freight"]
3 SET sorted TO False
4 SET index TO 0
5
6 SEND "Enter package weight in grams" TO DISPLAY
7 RECEIVE weight FROM (INTEGER) KEYBOARD
8
9 WHILE (sorted = True) AND (index < LENGTH(weightThresholds)) DO
10     IF (weight > weightThresholds[index]) THEN
11         SET index TO index + 1
12     ELSE
13         SET sorted TO True
14     END IF
15 END WHILE
16 SEND shippingCategory[index] TO DISPLAY

The pseudo-code produces an incorrect output.

When the user enters 350, the algorithm outputs "Standard". The correct output should be "Priority".

State the name for this type of error.

[1]
Markscheme

Computational thinking Questions

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

Question bank