How to calculate Compound Interest in Java ?.

Program to calculate Compound Interest in Java

import java.util.Scanner;

public class CompoundInterest {

   public static void main(String[] args) {
      Scanner input = new Scanner(System.in);

      double principal = 0;
      double rate = 0;
      double time = 0;

      double compoundInterest = 0;
  
      System.out.print("Enter the Principal amount : "); 
      principal = input.nextDouble();

      System.out.print("Enter the Rate : "); 
      rate = input.nextDouble();

      System.out.print("Enter the Time : "); 
      time = input.nextDouble();

      compoundInterest = principal * Math.pow((1 + rate/100),time); 
  
      System.out.println("");
      System.out.println("The Compound Interest is : "
     + compoundInterest);
  
   }

}






Output of the program :