doing an online book class on C++ and up to the chapter about "while loops".
their is a sample problem that ask:
"Suppose we add a fixed amount of money into our bank account at the beginning of every year. Modify the program from this section to show how many years it takes for the balance to double, given the annual contributions and the interest. Also print the final balance."
the correct outputs according to the book is:
with an annual contribution of 100$: Year: 13
Balance: 20527.8
the output i am getting with my program is: Year: 13
Balance: 20627.8
i'm not sure what i am doing wrong, it seems according to the instructions that i loop in adding the contribution and interest amount to each years balance. my code is as follows: