Java Program to find Compound Interest

by | Jan 13, 2023 | Java, Java Programs

Home » Java » Java Programs » Java Program to find Compound Interest

Introduction

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

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

Example

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
import java.io.*
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);
}
}

 

OUTPUT
Compound Interest is 1333.099243

 

Author

0 Comments

Submit a Comment

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.

Author