Skip to content

Commit 8a16975

Browse files
authored
Create simpleInterest.java
1 parent 68c9cd1 commit 8a16975

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

simpleInterest.java

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

0 commit comments

Comments
 (0)