- Write a Java program called Login.java that determines whether the user has entered a valid password or not. Your program should satisfy the following requirements.
Design and implement a Java program where your program asks user to enter username and password, and print "Welcome, < username>!" if they match, or "Wrong password!" if not. The matching is done as follows:
- The username may be entered in mix of letters and numbers.
- Your program will read password from "username.txt" file. For example, if the username is ejung, then her password is stored in ejung.txt. You will need to create a few files for your testing. If the file does not exist, then print "No such user".
- If the password is the same as the password in the file, then the username and the password is a match.
Example executions: Assume that we have ejung.txt that contains ejung, and johndoe.txt that contains janedoe, but no janedoe.txt.
Enter username: ejung
Enter password: ejung
Welcome, ejung!
Enter username: johndoe
Enter password: janedoe
Welcome, johndoe!
Enter username: johndoe
Enter password: johndoe
Wrong password!
Enter username: janedoe
No such user
- Extra credit (up to 10%): After 3 failed attempts to login, your program terminates.
- Write 1~2 paragraphs that explains how your program works in README file. Answer the following question in your README.
- Can you check if the password matches guidelines, such as containing numbers and special characters?
- Submit README and Login.java to SVN at
https://www.cs.usfca.edu/svn/username/cs112/lab2
SVN instructions here.