Simple loop, cant find a simple reason it doesnt do anything.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

int main()
{
 using namespace std;

const double DaphneInterest = .05;
const double 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.

Any ideas?
um. worked fine for me (just adda cin.get() to keep the console open)..
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.
Topic archived. No new replies allowed.