-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterestRates.java
More file actions
62 lines (31 loc) · 860 Bytes
/
InterestRates.java
File metadata and controls
62 lines (31 loc) · 860 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Scanner;
public class InterestRates {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
double principal;
double rate;
double rate1;
double years;
double sumrate;
double sumrate1;
double sumrate2;
double sumrate3;
double month;
double yearlyrate;
double monthlyrate;
System.out.println(" Enter principal amount");
principal = input.nextDouble();
System.out.println("Enter annual interest rate");
yearlyrate = input.nextDouble();
System.out.println("Enter yearly duration rate");
years = input.nextInt();
rate = yearlyrate / 100 /12 ;
month = years * 12;
sumrate = rate + 1;
sumrate1 = Math.pow(sumrate , month);
sumrate2 = sumrate1 * rate;
sumrate3 = sumrate1 - 1;
monthlyrate = (principal * sumrate2) / sumrate3;
System.out.print("monthly rate is " + "$" + monthlyrate);
}
}