-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
37 lines (24 loc) · 974 Bytes
/
Copy pathMain.java
File metadata and controls
37 lines (24 loc) · 974 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
import java.sql.SQLOutput;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
//compound interest calculator
Scanner input = new Scanner(System.in);
double principal;
double rate;
int timesCompounded;
int years;
double amount;
System.out.print("Enter the principal amount: ");
principal = input.nextDouble();
System.out.print("Enter the interest rate (in %): ");
rate = input.nextDouble()/100;
System.out.print("Enter the number of times compounded for year: ");
timesCompounded = input.nextInt();
System.out.print("Enter the number of years: ");
years = input.nextInt();
amount = principal * Math.pow(1 + rate / timesCompounded, timesCompounded*years);
System.out.println("The amount after "+ years+" is: $"+amount);
input.close();
}
}