Compound Interest Calculator
Compound interest can be calculated with the following formula.
A = Amount
P = Principal
R = Rate
n = Years
We can calculate the amount in Java as shown below. We currently know the principal (10,000) and the rate (1%). The years can change depending on how much information we want. In this application, we'll just use 20.
We initialise our variables as per usual. We then construct a For Loop which will give us 20 iterations. Using our formula, we calculate the amount. We used the Math.pow function because it allows us to use indices. The first parameter is what you want in the parentheses and the second parameter is what you want the power to be. Quite a simple calculator.