Skip to content

Commit f77f7fb

Browse files
author
sudarshan412
authored
Added Compound Interest program
1 parent 9fd3485 commit f77f7fb

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

compundinterest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#https://www.facebook.com/suyash.ssp/posts/2629289193987053
2+
#posted by suyash
3+
4+
public class JavaExample {
5+
6+
public void calculate(int p, int t, double r, int n) {
7+
double amount = p * Math.pow(1 + (r / n), n * t);
8+
double cinterest = amount - p;
9+
System.out.println("Compound Interest after " + t + " years: "+cinterest);
10+
System.out.println("Amount after " + t + " years: "+amount);
11+
}
12+
public static void main(String args[]) {
13+
JavaExample obj = new JavaExample();
14+
obj.calculate(2000, 5, .08, 12);
15+
}
16+
}

0 commit comments

Comments
 (0)