Past-paper question · 2021 May-June · Paper 22 · Q4(b)

Question 4(b) 2021 · May-June · Paper 22 · 4 marks

Original past-paper question for 4(B)
Original past-paper question for 4(B)
Reveal official mark-scheme answer Official mark-scheme answer for 4(B)

Official answer for Question 4

Part (b)

✓
Any four from:

Question 4

  • Position: before INPUT PasswordRepeat // at start
  • …use a (variable) counter (for number of tries) or flag
  • … initialise variable counter or flag
✓
•
✓
Position after IF Length(Password) >= 8 THEN or after INPUT PasswordRepeat
✓
•
✓
… insert REPEAT/WHILE/(conditional) loop
✓
•
✓
Position after OUTPUT "Reject"
✓
•
✓
… add one to counter (for number of tries)
✓
•
✓
… output a message "Try again"
✓
•
✓
… add INPUT PasswordRepeat
✓
•
✓
Position after OUTPUT "Accept"
✓
•
✓
… reset flag to show password matched
✓
•
✓
Position after ENDIF
✓
•
✓
… (insert UNTIL/ENDWHILE)to exit the loop after three tries or if the repeated password matches the original
✓
Question
✓
Answer
✓
Marks

Mark scheme 2210_s21_ms_22.pdf →

Show text version of question

Question 4

Part (b)

Question 4

This algorithm checks passwords.

  • Each password must be 8 or more characters in length; the predefined function Length
  • returns the number of characters.

  • Each password is entered twice, and the two entries must match.
  • Either Accept or Reject is output.
  • An input of 999 stops the process.

REPEAT OUTPUT "Please enter password" INPUT Password IF Length(Password) >= 8 THEN INPUT PasswordRepeat IF Password <> PasswordRepeat THEN OUTPUT "Reject" ELSE OUTPUT "Accept" ENDIF ELSE OUTPUT "Reject" ENDIF UNTIL Password = 999

Part (b)

Explain how the algorithm could be extended to allow three attempts at inputting the matching

password. Any pseudocode statements used in your answer must be fully explained.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................

[4]
Topic relevance

Why this question appears here

83% assigned-topic match · Algorithm design and problem-solving

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 2210_s21_qp_22.pdf

Keep practising this topic