-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestLoanEligibility.java
More file actions
33 lines (33 loc) · 1014 Bytes
/
Copy pathTestLoanEligibility.java
File metadata and controls
33 lines (33 loc) · 1014 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 TestLoanEligibility{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
System.out.println("Enter your age ");
int age=sc.nextInt();
System.out.println("Enter your salary ");
int salary=sc.nextInt();
LoanEligibility c=new LoanEligibility();
try{
c.checkEligibility(age,salary);
}
catch (LoanEligibilityException e){
System.out.println(e.getMessage());
}
}
}
class LoanEligibilityException extends Exception{
LoanEligibilityException(String message) {
super(message);
}
}
class LoanEligibility{
void checkEligibility(int age, int salary) throws LoanEligibilityException{
if( age<=18 || salary<=25000){
throw new LoanEligibilityException("Not eligible for loan");
}
else{
System.out.println("Loan approved");
}
}
}