Develop a program to accept a Password from the user and throw “Authentication Failure” exception if the password is incorrect
import java.util.*;
class Test
{
public static void main(String args[])
{
try
{
System.out.println("Enter Password:
");
Scanner obj=new Scanner(System.in);
String pass= obj.nextLine();
if(!pass.equals("1234"))
System.out.println("Authentication
Failure");
else
System.out.println("Welcome....!!");
}
catch (Exception e)
{
System.out.println("");
}
finally
{
System.out.println("Thank
You.........!!!!!");
}
}
}
Comments
Post a Comment