An engineer reviews the algorithm shown in Figure 1 and makes the following statement:
"Currently, if the user enters 'y' or 'n' instead of 'yes' or 'no', 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 'y' instead of 'yes' 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 'Are you a registered member?'
2 memberStatus ← USERINPUT
3 IF memberStatus = 'yes' THEN
4 OUTPUT 'Do you have a discount code?'
5 discountCode ← USERINPUT
6 IF discountCode = 'yes' THEN
7 OUTPUT 'Apply 20% discount at checkout'
8 ELSE
9 OUTPUT 'No discount applied'
10 ENDIF
11 ELSE
12 OUTPUT 'Do you want to sign up today?'
13 signUp ← USERINPUT
14 IF signUp = 'yes' THEN
15 OUTPUT 'Redirecting to registration'
16 ELSE
17 OUTPUT 'Continuing as guest'
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.