P-Cubed classifies items as letters and packages according to their weight - Edexcel - GCSE Computer Science - Question 4 - 2018 - Paper 1
Question 4
P-Cubed classifies items as letters and packages according to their weight.
Here is the pseudo-code for an algorithm that determines the classification of an item.
... show full transcript
Worked Solution & Example Answer:P-Cubed classifies items as letters and packages according to their weight - Edexcel - GCSE Computer Science - Question 4 - 2018 - Paper 1
Step 1
State the name for this type of error.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Logic error. This occurs because the condition for classifying the item is flawed, leading to incorrect output.
Step 2
Identify the error in Line 11 and construct new lines of pseudo-code that will correct the errors.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Error: The loop never executes (Line 11) because 'found' is initialized to False.
Correction: Change Line 11 to 'WHILE (found = False) AND (i < LENGTH(maxWeights)) DO'.
Step 3
Identify the error in Line 18 and construct new lines of pseudo-code that will correct the errors.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Error: It prints the wrong item type (Line 18); it prints the item type to the right of the correct one.
Correction: Change Line 18 to 'SEND typeItem[i] TO DISPLAY'.