-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD2-13.txt
39 lines (32 loc) · 1.28 KB
/
D2-13.txt
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
35
36
37
38
39
class Loan{
private float interest;
Loan(){
interest = 8.5f;
}
//calculateEMI overloaded methods
public double calculateEMI(int tenure, double principal){
double simpleInterest = (principal * interest * tenure) / 100;
return (simpleInterest+principal)/tenure;
}
public double calculateEMI(double principal, int tenure){
double simpleInterest = (principal * interest * tenure) / 100;
return (simpleInterest+principal)/tenure;
}
public double calculateEMI(int tenure, double principal, float interest){
double simpleInterest = (principal * interest * tenure) / 100;
return (simpleInterest+principal)/tenure;
}
public static void main(String[] args){
Loan loan = new Loan();
double result = loan.calculateEMI(20000d, 5); //d means double
double value = loan.calculateEMI(5, 20000d);
double val = loan.calculateEMI(5, 20000, 9.5f); // f means float
System.out.println("EMI per year is..." + result);
System.out.println("EMI per year is..." + value);
System.out.println("EMI per year is..." + val);
}
}
Output:
EMI per year is...5700.0
EMI per year is...5700.0
EMI per year is...5900.0