You are here: Home / Topics / Java Program for Calculating Interest

Java Program for Calculating Interest

Filed under: Java on 2023-08-11 19:07:39

// Simple example to calculate Interest

class  CompInterest
{
public static void main( String args[ ] )
{
 double a, p, r ,n ,ci;

 p = 1000;
 r = 10;
 n = 3;

      a = p * Math.pow(( 1 + ( r / 100.0 ) ), n );
      ci = a - p;

     System.out.println( " Amount = " + a );
 System.out.println( " Compound interest = "  + ci );
   }
}


Output:

Amount = 1331.0000000000005
Compound interest = 331.000000000000045

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.