194k views
4 votes
Consider the following code segment that appears in the middle of a program.

display [what is the password?]
EnterPassword<-- input
Repeat Until (missing statement)
display[invalid, try again]
userPassword <--- Input
Which of the following can replace the missing statement in the REPEAT UNTIL block so that the user will be required to enter the correct password of "swordfish" before they can continue on with the rest of the program.
Option 1: userPassword is equal to "swordfish"
Option 2: userPassword not equal to "swordfish"
Option 3: EnterPassword is not empty
Option 4: display "Access granted"

1 Answer

7 votes

Final answer:

The missing statement in the REPEAT UNTIL block should be the userPassword not equal to 'swordfish'.

Step-by-step explanation:

In the given code segment, the missing statement in the REPEAT UNTIL block should be Option 2: userPassword not equal to 'swordfish'. This statement requires the user to enter any password that is not equal to 'swordfish' in order to repeat the block again, informing them that the entered password is invalid. If the user enters 'swordfish', the block will not repeat and the program will continue with the rest of the code.

User Dejuknow
by
8.0k points