You deposit the same amount at the end of every month in an account that pays interest monthly. Write SavingsGoal: read the goal, the monthly deposit and the annual interest rate in percent. Each month: add the interest on the current balance (balance × rate / 100 / 12), then the deposit. Stop when the balance reaches the goal.
Print the balance after each full year, then the number of months, the final balance, the total deposited and the interest earned. A deposit ≤ 0 prints The monthly deposit must be positive.
For the input
10000 800 3
the program prints
After year 1: 9733.11
Goal reached after 13 months (1 years and 1 months)
Final balance: 10557.44
Deposited: 10400.00, interest earned: 157.44