Lab 2 due by 11:55pm on Wed. Feb. 8

  1. Write a Java program called that determines whether the user has entered a valid password or not. Your program should satisfy the following requirements.

  2. 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:

    1. The username may be entered in mix of letters and numbers.
    2. 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".
    3. 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
  3. Extra credit (up to 10%): After 3 failed attempts to login, your program terminates.
  4. Write 1~2 paragraphs that explains how your program works in README file. Answer the following question in your README.

  5. Submit README and to SVN at
    SVN instructions here.