Skip to main content
O-LevelComputer ScienceAlgorithm design and problem-solving2210/22 · May/June 2021 · Q47 Marks

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

  1. (a)Complete the trace table for the algorithm using this input data: Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999, 888 Password PasswordRepeat OUTPUT[3]
  2. (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]

Mark scheme

Marking points from the official mark scheme (May/June 2021). The mark or mark type is shown in brackets.

  1. [1] Password column correctly filled with inputs in order: Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999 (excluding prompt for each input)
  2. [1] PasswordRepeat column correctly filled with inputs in order: (empty), (empty), VerySecret, (empty), Pa55word, (empty), (empty) (excluding prompt for each input)
  3. [1] OUTPUT column correctly filled with outputs in order: (Please enter password), Reject, (Please enter password), Reject, (Please enter password), Accept, (Please enter password), Accept, (Please enter password), Reject
  4. [1] Any four from: Position: before INPUT PasswordRepeat // at start
  5. [1] ...use a (variable) counter (for number of tries) or flag
  6. [1] ... initialise variable counter or flag
  7. [1] Position after IF Length(Password) >= 8 THEN or after INPUT PasswordRepeat
  8. [1] ... insert REPEAT/WHILE/(conditional) loop
  9. [1] Position after OUTPUT "Reject"
  10. [1] ... add one to counter (for number of tries)
  11. [1] ... output a message "Try again"
  12. [1] ... add INPUT PasswordRepeat
  13. [1] Position after OUTPUT "Accept"
  14. [1] [1] ... reset flag to show password matched
  15. [1] Position after ENDIF
  16. [1] ... (insert UNTIL/ENDWHILE) to exit the loop after three tries or if the repeated password matches the original

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Algorithm design and problem-solving, O-Level Computer Science (syllabus 2210). Structured question, 7 marks.
Source
O-Level Computer Science, May/June 2021 Paper 2 Variant 2, question 4.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep