import java.io.*;
import java.util.*;
class Login extends Exception {
            Login(String Message) {
                        super(Message);
            }
}
class Authentication {
            public static void
main(String args[]) throws IOException {
                        Scanner
sc=new Scanner(System.in);
                        String
password1="Program";
                        String
password2;
                        System.out.print("Enter
the password = ");
                        password2=sc.nextLine();
                        try {
                                    if(password1.equals(password2))
                                                System.out.println("Password
Correct.");
                                    else
{
                                                Login
f1=new Login("Incorrect Password.");
                                                throw
f1;
                                    }
                        }
catch(Login e) {
                                    System.out.print(e);
                        }
            }
}
No comments:
Post a Comment