-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD3-2.txt
29 lines (24 loc) · 872 Bytes
/
D3-2.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
class Loan {
public double calculateEMI(double principal) {
double simpleInterest = (principal*8.5*5) / 100;
double emi = (simpleInterest+principal)/5;
return emi;
}
}
class HomeLoan extends Loan {
public double calculateEMI(double principal) {
int additionaltax = 200;
double emi = super.calculateEMI(principal); //calling super class method
return emi + additionaltax;
}
}
class ExecuteLoan {
public static void main(String[] args) {
Loan loan = null;
loan = new HomeLoan(); // Runtime polymorphism
double hloan = loan.calculateEMI(2000000);
System.out.println("Home loan emi per year..."+ hloan);
}
}
Output:
Home loan emi per year...570200.0