Java Program to find Compound Interest


This article illustrates that a Java program can calculate compound interest on a sum of money.

The formula to calculate compound interest on a sum of money is as follows:

Compound Interest = P (1 + R/100) ^ r

P is the principal Amount
R is the rate of interest
T is the time span.


Input: Principle (amount): 1200
Time: 2
Rate: 5.4
OUTPUT: Compound Interest = 1333.099243

Sample Code

//Java Program to find compound interest for the given values

class Demo
public static void main (String args [])
double principle = 1200, rate = 5.4, time = 2;
//Calculate Compound Interest
double CI = principle * (Math.pow ( (1 + rate / 100), time));
System.out.println (“Compound Interest is: ” + CI);


Compound Interest is 1333.099243



  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.