Skip to content

Commit fdaa5a6

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#111 from rvrahul5656/patch-1
Create Java Program to calculate Compound Interest.java
2 parents c4be675 + 9b15438 commit fdaa5a6

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)