-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCI.java
More file actions
37 lines (19 loc) · 825 Bytes
/
CI.java
File metadata and controls
37 lines (19 loc) · 825 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.util.Scanner;
public class CI {
public static void main(String args[]) {
float principal, rate, time;
System.out.println("\n Compound Interest Calculator \n");
System.out.println("$ Enter the principal: ");
Scanner scanner = new Scanner(System.in);
principal = scanner.nextFloat();
System.out.println("$ Enter the rate: ");
rate = scanner.nextFloat();
System.out.println("$ Enter the time: ");
time = scanner.nextFloat();
scanner.close();
float amount = principal * (float) Math.pow((1 + (rate / 100)), time);
float compoundInterest = amount - principal;
System.out.printf("\n Amount: %.4f \n", amount);
System.out.printf("Compound Interest: %.4f \n", compoundInterest);
}
}