Arthur is installing a safety fence around a rectangular outdoor swimming pool area. The pool area is 12 metres long and 6 metres wide. One of the longer sides runs along an existing high brick wall, so fencing is not needed on that side.
The pseudocode for an algorithm that calculates the total length of fencing required is shown below.
Line 5 and Line 7 contain logic errors.
Identify the error in each line and construct new lines of pseudocode that will correct the errors.
1 SEND "Enter length: " TO DISPLAY
2 RECEIVE length FROM (INTEGER) KEYBOARD
3 SEND "Enter width: " TO DISPLAY
4 RECEIVE width FROM (INTEGER) KEYBOARD
5 SET totalLength TO 2 * length
6 SET totalWidth TO 2 * width
7 SET total TO totalLength * totalWidth
8 SEND "Fencing needed: " & total TO DISPLAY
| Line | Error | Correction |
|---|---|---|
| Line 5 | ||
| Line 7 |