asked 187k views
2 votes
Write a pseudocode algorithm that asks a user for a password. They are allowed three attempts to type the correct password, which is “Tues1212”. If they type the correct password, output “Password accepted”, otherwise output “Password rejected”.

asked
User Nitrogen
by
7.9k points

1 Answer

3 votes
1. Set the variable "attempts" to 0.
2. Set the correct password as "Tues1212".
3. While "attempts" is less than 3:
a. Prompt the user to enter a password.
b. Read the user's input into a variable "userPassword".
c. If "userPassword" is equal to the correct password:
i. Output "Password accepted."
ii. Exit the loop.
d. Else:
i. Output "Password rejected. You have X attempts remaining."
ii. Increment "attempts" by 1.
4. If "attempts" reaches 3:
a. Output "You have exceeded the maximum number of attempts. Access denied."
answered
User JonMayer
by
8.8k points