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.
| Error | Correction | |
|---|---|---|
| Line 8 | ||
| Line 10 |