Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help ASAP and I can reward you if done!
#3
Ok. Here's what you want:

Code:
import java.io.*;

class PasswordChecker
{
    private String $PasswordStored="Password"; //This is the stored Password.
    
    private void inputPassword()
    {
        /*
           This method accepts the password from the user and
           checks whether it is correct.
        */
        try
        {
            String $PasswordEntered = new String();
            int varCounter = 0;
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            while (varCounter<3)
            {
                System.out.println("Enter the Password:");
                $PasswordEntered = br.readLine();
                
                if ($PasswordEntered.equals($PasswordStored))
                {
                    System.out.println("Welcome");
                    System.exit(0);
                }
                else
                {
                    System.out.println("The password you typed is incorrect.");
                }
                
                varCounter++;
            }
            
            System.out.println("Access Denied");
            System.exit(0);
        }
        catch(Exception error)
        {
            System.out.println("Error: "+error.toString());
        }
    }
    
    public static void main(String args[])
    {
        try
        {
            PasswordChecker PC = new PasswordChecker();
            PC.inputPassword();
        }
        catch(Exception error)
        {
            System.out.println("Error: "+error.toString());
        }
    }
    
}
Reply


Messages In This Thread
RE: I need help ASAP and I can reward you if done! - by aHardyX - 03-17-2012, 12:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)