An engineer reviews the smart home control algorithm shown in Figure 1 and makes the following statement:
"Currently, if the user enters 'arm' instead of 'armed' when prompted, they will sometimes get unexpected results. This design flaw could have been easily prevented."
Explain why this problem has occurred and describe what would happen if a user entered 'arm' instead of 'armed' when prompted at line 2.
You may include references to line numbers in the algorithm where appropriate. You do not need to write or correct any of the pseudocode.
Figure 1
1 OUTPUT 'Is the security system armed?'
2 systemStatus ← USERINPUT
3 IF systemStatus = 'armed' THEN
4 OUTPUT 'Is the entry door sensor active?'
5 sensorStatus ← USERINPUT
6 IF sensorStatus = 'active' THEN
7 OUTPUT 'Trigger primary alarm'
8 ELSE
9 OUTPUT 'System secure - monitoring'
10 ENDIF
11 ELSE
12 OUTPUT 'Do you want to arm the system now?'
13 armNow ← USERINPUT
14 IF armNow = 'armed' THEN
15 OUTPUT 'System arming sequence initiated'
16 ELSE
17 OUTPUT 'System remains disarmed'
18 ENDIF
19 ENDIF
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.