Compound Interest (CI) is the interest calculated on both the original principal amount and the accumulated interest from previous periods. Unlike simple interest, compound interest allows the investment or loan amount to grow faster because interest is earned on previously earned interest.
- Produces higher returns than simple interest over the same period.
- Commonly used in savings accounts, fixed deposits, loans, and investments.
- Uses the Math.pow() method in Java to calculate powers.
Illustration
Input: P = 10000 R = 10 T = 2
Output: Compound Interest = 2100.0
Amount = 12100.0
Formula
\text{Compound Interest} = P \left(1 + \frac{R}{100}\right)^T - P
Amount Formula:
A = P \left(1 + \frac{R}{100}\right)^T \text{Compound Interest} = A - P
Example: Calculate Compound Interest
public class GFG {
public static void main(String[] args) {
double P = 10000;
double R = 10;
double T = 2;
// Calculate total amount
double amount = P * Math.pow(1 + R / 100, T);
// Calculate compound interest
double CI = amount - P;
System.out.println("Compound Interest = " + CI);
System.out.println("Amount = " + amount);
}
}
Output
Compound Interest = 2100.000000000002 Amount = 12100.000000000002
Explanation: The program initializes the principal amount, interest rate, and time period. It uses the compound interest formula along with the Math.pow() method to calculate the final amount. The compound interest is then obtained by subtracting the principal amount from the total amount.