-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCI.java
More file actions
47 lines (24 loc) · 944 Bytes
/
CI.java
File metadata and controls
47 lines (24 loc) · 944 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
import java.io.*;
import java.util.*;
public class CI {
public void calculate(int p, int t, double r, int n) {
double a = p * Math.pow(1 + (r / n), n * t);
double cinterest = a - p;
System.out.println("Compound Interest after " + t + " years: "+cinterest);
System.out.println("Amount after " + t + " years: "+a);
}
public static void main(String args[]) {
int p,t,n;
double r;
CI obj = new CI(); Scanner s=new Scanner(System.in);
System.out.print("Enter the principal amount : ");
p=s.nextInt();
System.out.print("Enter the time the money is invested or borrowed for : ");
t=s.nextInt();
System.out.print("Enter the the annual interest rate : ");
r=s.nextDouble();
System.out.print("Enter the number of times that interest is compounded per unit t : ");
n=s.nextInt();
obj.calculate(p,t,r,n);
}
}