In C++, I can't get the following code to calculate interest correctly. It's supposed to calculate the money like this.

1 : 1000

2 : 2050 (1000(1.05) + 1000)

3 : 3152.5 (2050(1.05) + 1000)

4 : 4310.125 (3152.5(1.05) + 1000)

But, instead, it calculates my interest like this.

1 : 1000

2 : 2050

3 : 4310.12

4 : 8142.01

Looking at the results, I really can't tell what's going on.

```
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
    bool done;
    char finished;
    int numberOfYears;
    double accountBalance = 1000;
    int i;
    const double rateOfInterest = 1.05;
    const int yearlyIncome = 1000;
    while (!done){
        cout << "Enter the number of years you've kept your\n"
             << "money in your bank account." << endl;
        cin >> numberOfYears;
        for (i = 1; i < numberOfYears; i++){
            accountBalance *= rateOfInterest;
            accountBalance += yearlyIncome;
        }
        cout << "Balance = $" << accountBalance << endl;
        cout << "If you are finished, enter y, otherwise,\n"
             << "enter any key." << endl;
        cin >> finished;
        if (finished == 'y' || finished == 'Y') done = true;
    }
    return 0;
}

```