Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
Question 81

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
[3]
Markscheme

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts

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.

Question bank