Last Updated: 20 April, 2023
On this tutorial page we are going to learn what is compound interest and how to write a Java program to calculate compound interest.
Compound interest is the interest that is earned not only on the principal amount, but also on the accumulated interest from previous periods. To calculate compound interest, you need to know the principal amount, the interest rate, the number of compounding periods per year, and the length of time for which the interest is being calculated.
The formula for calculating compound interest is:
A = P(1 + r/n)^(nt)
Where:
Example: Calculate Compound Interest in Java
Output
Enter the Principal Amount: 500000
Enter the Rate of interest: 7.2
Enter the Time period (in Years): 5
Enter number of times interest is compounded: 1
Compound Interest: 207854.38580159063
That's all guys, hope this Java Program is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com