Here you will get java program to calculate compound interest.
We can calculate compound interest by following formula.
Compound Interest = Principle * (1 + Rate / 100) time
Also Read: Java Program to Calculate Simple Interest
import java.util.Scanner; public class JavaCompoundInterest { public static void main(String args[]){ double p, r, t, ci; Scanner sc = new Scanner(System.in); System.out.print("Enter principle: "); p = sc.nextDouble(); System.out.print("Enter rate: "); r = sc.nextDouble(); System.out.print("Enter time: "); t = sc.nextDouble(); ci = p * (Math.pow(1 + (r / 100), t)); System.out.print("\nCompound Interest = " + ci); } }
Output
Enter principle: 1000
Enter rate: 4
Enter time: 10
Compound Interest = 1480.2442849183444