AQA GCSE · Question 06 · Fundamentals of algorithms
Figure 5 shows an algorithm for a simple authentication routine. Parts of the algorithm are missing and have been replaced with the labels L1 to L4.
Figure 5
login ← False
REPEAT
username ← ""
WHILE username = ""
OUTPUT 'Enter username: '
username ← L1
ENDWHILE
password ← ""
WHILE password = ""
OUTPUT 'Enter password: '
password ← USERINPUT
ENDWHILE
storedPassword ← getPassword(L2)
IF storedPassword = L3 THEN
OUTPUT L4
ELSE
IF password = storedPassword THEN
login ← True
ELSE
OUTPUT 'Try again.'
ENDIF
ENDIF
UNTIL login = True
OUTPUT 'You are now logged in.'
State the items from Figure 6 that should be written in place of the labels in the algorithm in Figure 5. You will not need to use all the items.
Figure 6
-1 OUTPUT 0 username True SUBROUTINE 1 User not found "" USERINPUT password Wrong password
Figure 5 shows an algorithm for a simple authentication routine. Parts of the algorithm are missing and have been replaced with the labels L1 to L4.
Figure 5
login ← False
REPEAT
username ← ""
WHILE username = ""
OUTPUT 'Enter username: '
username ← L1
ENDWHILE
password ← ""
WHILE password = ""
OUTPUT 'Enter password: '
password ← USERINPUT
ENDWHILE
storedPassword ← getPassword(L2)
IF storedPassword = L3 THEN
OUTPUT L4
ELSE
IF password = storedPassword THEN
login ← True
ELSE
OUTPUT 'Try again.'
ENDIF
ENDIF
UNTIL login = True
OUTPUT 'You are now logged in.'
State the items from Figure 6 that should be written in place of the labels in the algorithm in Figure 5. You will not need to use all the items.
Figure 6
| -1 | OUTPUT | 0 |
|---|---|---|
| username | True | SUBROUTINE |
| 1 | User not found | "" |
| USERINPUT | password | Wrong password |
How to approach this question
Full Answer
Common mistakes
Practice the full AQA GCSE Computer Science Paper 1 Python
31 questions · hints · full answers · grading
Expert