Pin It

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 :



Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot