#include <iostream>
int main()
{
usingnamespace std;
constdouble DaphneInterest = .05;
constdouble CleoInterest = 1.05;
double Daphne = 100;
double Cleo = 100;
long year;
for (year = 1; Cleo <= Daphne; year++)
{
Daphne = 100 + ( year * (100.0 * DaphneInterest));
Cleo *= CleoInterest;
}
cout << "Cleo is at: " << Cleo << " and Daphne is at: " << Daphne << ". It took " << year <<
" years for Cleo to start making more money!" << endl;;
return 0;
}
Thats the code I've got for a simple loop, I just want it to preform a simple calculation of interests.
Daphne gets 10% interest on the original investment 100. Each year.
Cleo gets 5% compound interest, so she gets 5% of the current balance added each year.
So i'm using a for loop to check when Cleo will exceed Daphne in balance. But right now my console window just stares blankly at me.
It seems the function never gets to the loop, at all. I just don't get what im doing wrong. I've tried a do while loop, a while loop all in the same format but with the year increment and such changing.
For some reason my compiler messed up and the console window had two processes of the same program running, causing an issue.
Basically I just ended those processes and it ran fine. Feels great to spend like 2 hours trying to figure out what I did wrong to find out I did nothing wrong at all. Thanks though.