The algorithm in Figure 1 is designed to check if a chemical reaction's target temperature is valid (at least 80 degrees Celsius) and calculate the required temperature rise from a starting temperature. It contains a logic error on line 11.
Figure 1
1 validRun ← False
2 REPEAT
3 tempRise ← 0
4 OUTPUT 'Enter starting temperature: '
5 startingTemp ← USERINPUT
6 OUTPUT 'Enter target temperature: '
7 targetTemp ← USERINPUT
8 IF startingTemp ≥ targetTemp THEN
9 OUTPUT 'Starting temperature must be less than target temperature'
10 ELSE
11 IF targetTemp ≥ 80 THEN
12 OUTPUT 'Target temperature must be at least 80 degrees'
13 ELSE
14 validRun ← True
15 ENDIF
16 ENDIF
17 UNTIL validRun = True
18 tempRise ← targetTemp - startingTemp
19 OUTPUT tempRise
Describe how the error on line 11 can be corrected.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.