Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe to all free courses

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 :



 
© 2021 Learn Java by Examples Template by Hubberspot