To implement a program that calculates compound interest.
Compound interest is the addition of interest to the principal sum of a loan or deposit, or in other words, interest on principal plus interest. Unlike simple interest, which is calculated only on the initial amount, compound interest takes into account the interest that accumulates over time. It is the result of reinvesting interest, rather than paying it out, so that interest in the next period is then earned on the principal sum plus previously accumulated interest.
The compound interest is calculated using the formula:
For an initial principal of P, rate of interest per annum of r (r%), time period t in years, frequency of the number of times the interest is compounded annually n, the formula to calculate the total compounded amount is as follows:
A = P (1 + r/n)nt
If compound interest calculate once in a year, then
A = P (1 + r)t
For example, If Rs. 5000 is invested in a bank where the amount is compounded continuously at a rate of 7% per year, then the resultant amount after 3 years will be Rs.6125.21