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
- (a)Complete the trace table for the algorithm using this input data: Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999, 888 Password PasswordRepeat OUTPUT[3]
- (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] Password column correctly filled with inputs in order: Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999 (excluding prompt for each input)
- [1] PasswordRepeat column correctly filled with inputs in order: (empty), (empty), VerySecret, (empty), Pa55word, (empty), (empty) (excluding prompt for each input)
- [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
- [1] Any four from: Position: before INPUT PasswordRepeat // at start
- [1] ...use a (variable) counter (for number of tries) or flag
- [1] ... initialise variable counter or flag
- [1] Position after IF Length(Password) >= 8 THEN or after INPUT PasswordRepeat
- [1] ... insert REPEAT/WHILE/(conditional) loop
- [1] Position after OUTPUT "Reject"
- [1] ... add one to counter (for number of tries)
- [1] ... output a message "Try again"
- [1] ... add INPUT PasswordRepeat
- [1] Position after OUTPUT "Accept"
- [1] [1] ... reset flag to show password matched
- [1] Position after ENDIF
- [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 →