forked from iamshubhamg/Leet-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmi Calc.java
35 lines (26 loc) · 850 Bytes
/
Emi Calc.java
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
//program to calculate emi in java
import java.util.*;
import java.util.Scanner;
class Emi
{
public static void main(String []args)
{
Scanner a = new Scanner(System.in);
double principal, rate, time, emi;
System.out.print("Enter principal: ");
principal = a.nextFloat();
System.out.print("Enter rate: ");
rate = a.nextFloat();
System.out.print("Enter time in year: ");
time = a.nextFloat();
rate=rate/(12*100);
time=time*12;
emi= emiCalculation(principal,rate,time);
System.out.print("Monthly EMI is= "+emi+"\n");
}
static double emiCalculation(double p,double r,double t)
{
double e= (p*r*Math.pow(1+r,t))/(Math.pow(1+r,t)-1);
return e;
}
}