Skip to content

Course home

Sign up

Computational thinking

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
Question 49

An automated courier packing system uses the following algorithm to process up to 3 items inside a shipping box.

Individual items must not exceed 20 kg. If an item exceeds this limit, it is rejected as overweight and must not be added to the box. The maximum weight limit for the entire box is 40 kg.

1  SET totalWeight TO 0
2  SET currentItem TO 0
3
4  FOR count FROM 1 TO 3 DO
5      SEND "Enter item weight (kg):" TO DISPLAY
6      RECEIVE currentItem FROM (INTEGER) KEYBOARD
7
8      IF (currentItem = 20) THEN
9          SEND "Item is overweight - rejected" TO DISPLAY
10         SET totalWeight TO totalWeight + currentItem
11     ELSE
12         SET totalWeight TO totalWeight + currentItem
13         IF (totalWeight > 40) THEN
14             SEND "Total load limit exceeded" TO DISPLAY
15         END IF
16     END IF
17 END FOR

Line 8 and Line 10 cause logic errors.

Identify the error in each line and provide a correction for each.

ErrorCorrection
Line 8
Line 10
[4]
Markscheme

Computational thinking Questions

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

Question bank