QUOTE(magic0198 @ 14 Apr, 2008 - 01:44 PM)

I have to display how many days it will take to reach 4,843,378,958.00 by starting out with one penny and doubleing every day. The code I wrote doesnt work. When i execute my program it crashes.
This is what i have:
CODE
#include <iostream>
using namespace std;
/* Nick Mullins
4-14-08
Extra Credit2
CS115-J001
This program will display the number of days it will take
starting with one pennie doubleing every day to get
4,843,378,958.00
*/
int main()
{
int numday;
float daypay;
float total; //lcv
numday=0;
daypay=0.01;
total=0.00;
while(total<4,843,378,958.00){
numday++;
total=total+daypay;
daypay=daypay*2.0;
cout << "It took ";
cout << numday;
cout << " days to even 4,843,378,958.00";
cout << endl;
}
}
Try adding a,
System("PAUSE");
at the end of your program like this....
and also add a " to your
CODE
cout << " days to even 4,843,378,958.00;
like this
CODE
cout << " days to even 4,843,378,958.00";
CODE
#include <iostream>
using namespace std;
/* Nick Mullins
4-14-08
Extra Credit2
CS115-J001
This program will display the number of days it will take
starting with one pennie doubleing every day to get
4,843,378,958.00
*/
int main()
{
int numday;
float daypay;
float total; //lcv
numday=0;
daypay=0.01;
total=0.00;
while(total<4,843,378,958.00){
numday++;
total=total+daypay;
daypay=daypay*2.0;
cout << "It took ";
cout << numday;
cout << " days to even 4,843,378,958.00;
cout << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
ALL WORKS! I TESTED
This post has been edited by LoganLooker: 14 Apr, 2008 - 01:10 PM