Java – Calculate Compound Interest

Java Example to Calculate Compound Interest

Compound Interest = P (1 + R/n) (nt) – P

P — the principal investment amount (the initial deposit or loan amount)
r — the annual interest rate (decimal)
n — the number of times that interest is compounded per unit t
t — the time the money is invested or borrowed for

Java method to calculate compound interest with given P, t, r and n values.