formula of compound interest in java code example
Example: Java program to calculate compound interest
public class CompoundInterestDemo
{
public void calculateCompound(int p, int t, double r, int n)
{
double number = p * Math.pow(1 + (r / n), n * t);
double interest = number - p;
System.out.println("Compound interest after " + t + " years: " + interest);
System.out.println("Money after " + t + " years: " + number);
}
public static void main(String[] args)
{
CompoundInterestDemo obj = new CompoundInterestDemo();
obj.calculateCompound(200000, 6, .06, 12);
}
}