Note AcademyNote Academy

Computer Science · May / June 2022 · Paper 22 · Question 2

0478

As printed in the paper

The question as text

An algorithm allows a user to input their password and checks that there are at least eight characters in the password. Then, the user is asked to re-input the password to check that both inputs are the same. The user is allowed three attempts at inputting a password of the correct length and a matching pair of passwords. The pre-defined function LEN(X) returns the number of characters in the string, X 01 Attempt ← 0 02 REPEAT 03 PassCheck ← TRUE 04 OUTPUT "Please enter your password " 05 INPUT Password 06 IF LEN(Password) < 8 07 THEN 08 PassCheck ← TRUE 09 ELSE 10 OUTPUT "Please re-enter your password " 11 INPUT Password2 12 IF Password <> Password 13 THEN 14 PassCheck ← FALSE 15 ENDIF 16 ENDIF 17 Attempt ← Attempt + 1 18 UNTIL PassCheck OR Attempt <> 3 19 IF PassCheck 20 THEN 21 OUTPUT "Password success" 22 ELSE 23 OUTPUT "Password fail" 24 ENDIF

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

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

    One mark per mark point, max three

    line 8 / PassCheck ← TRUE

    correction PassCheck ← FALSE

    line 12 / IF Password <> Password

    correction IF Password2 <> Password // IF Password <> Password2

    line 18 / UNTIL PassCheck OR Attempt <> 3

    correction UNTIL PassCheck OR Attempt = 3 / UNTIL PassCheck OR Attempt >= 3

  • 2(b)[4]

    One mark check, one mark matching description, max four

    Check:

    validation

    // length check

    Description length check // checks number of characters in password

    Check:

    verification // double entry

    Description double entry // comparison that two inputs are the same

  • 2(c)[4]

    One mark per set, one mark matching reason, max four

    Set 1 –

    any appropriate example e.g. “small”

    Reason

    must follow through from the password given e.g. abnormal data will be rejected

    Set 2 –

    any different appropriate example e.g. “password” and “password”

    Reason

    must be different and follow through from the password given e.g. normal data will be accepted

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