// 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