Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 42

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

Algorithms Questions

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

159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank