Question
Create a text file UserPassword.txt with the following two lines: Alice P4ssword Write a program to complete the following tasks: 1.Upon execution, the program will
Create a text file UserPassword.txt with the following two lines:
Alice
P4ssword
Write a program to complete the following tasks:
1.Upon execution, the program will prompt the user to type in his/her name.
2.The program will compare with the typed in name with the name stored in UserPassword.txt (the first line of the file).
3.If the name does not match, the program will prompt user to reenter the name; if the name match, the program will proceed to ask for the password.
4.Give the user 3 times to enter password, and compare the typed in value with the password stored in UserPassword.txt (the second line of the file). If the password is correct, display a greeting message and terminate the program; otherwise, display an error message and terminate the program.
Following is an sample screen of the program in execution:
Welcome! Please enter User Name: Bob
User Name does not exist!
Welcome! Please enter User Name: Alice
Welcome back, Alice!
Please enter User Password: 123
Password for Alice entered incorrectly!
Please enter User Password: P4ssword
Congratulations! You have successfully logged in. (Or: You have entered incorrect password for 3 times, system is shutting down)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started