-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamPortal.java
More file actions
33 lines (33 loc) · 921 Bytes
/
Copy pathExamPortal.java
File metadata and controls
33 lines (33 loc) · 921 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
package BankAccounts;
import java.util.Scanner;
class ExamPortal{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int attempts=sc.nextInt();
ExamAccess c =new ExamAccess ();
try{
c.validateAccess(attempts);
}
catch(SecurityException e){
System.out.println(e.getMessage());
}
}
}
class SecurityException extends Exception{
SecurityException(String message){
super(message);
}
}
class ExamAccess{
void validateAccess(int attempts) throws SecurityException{
if(attempts>3){
throw new SecurityException("Account locked due to multiple failed attempts");
}
else if(attempts<=0){
System.out.println("Error! Try again ");
}
else{
System.out.println("Access granted");
}
}
}