Note AcademyNote Academy

Computer Science · May / June 2021 · Paper 22 · Question 4

0478

As printed in the paper

The question as text

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

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 4(a)[3]

    One mark for each correct column

    Password

    PasswordRepeat

    OUTPUT

    (Please enter password)

    Secret

    Reject

    (Please enter password)

    Secret

    Reject

    (Please enter password)

    VerySecret

    VerySecret

    Accept

    (Please enter password)

    Pa55word

    Pa55word

    Accept

    (Please enter password)

    999

    Reject

  • 4(b)[4]

    Any four from:

    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

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.