- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathUserdef.java
More file actions
Latest commit
34 lines (34 loc) · 888 Bytes
/
Copy pathUserdef.java
File metadata and controls
34 lines (34 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
importjava.util.Scanner;
classInvalidAccessextendsException{
publicInvalidAccess(Strings){
super(s);
}
}
publicclassUserdef
{
publicstaticvoidmain(Stringargs[])
{
Stringusername = "user1";
Stringpassword = "pass123";
Scannersc = newScanner(System.in);
System.out.print("Enter username: ");
Stringuser = sc.nextLine();
System.out.print("Enter password: ");
Stringpass = sc.nextLine();
try
{
if((user.equals(username)) && (pass.equals(password)))
{
System.out.println("ACCESS GRANTED");
}
else
{
thrownewInvalidAccess("Invalid Username or Password");
}
}
catch(InvalidAccesse)
{
System.out.println(e.getMessage());
}
}
}