This is my goal :Print out a table based on the number of days the user enters starting at one. List the pay for each day, the first days pay is a penny, but the pay doubles every day. Announce when the worker has earned $1000 and $1000000at the job.
I have both the loops i need but only the pay is being displayed..how can I get both to show?
int main ()
{
int day;
double n = .01;
cout << "Enter the starting day > ";
cin >> day ;
while (day < 1000) {
cout << day << " " ;
day++;
while (n< 1000)
{
cout << n << " \n";
n = n * 2;
}
Try getting rid of the return statement in the loop (cout << "1000!\n";// return 0; ). If you want to count from 0.01 in each iteration of the outer loop, you will need to set n to 0.01 in one of the loops as well.
#include <iostream>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
bool showonce = 0; // show $1000 only once
int days; // number of days on job
cout << "Enter starting day for job: ";
cin >> days;
for (double pay = .01; pay < 1000000; pay *= 2)
{
days++; // increment days by one
if (pay >= 1000 && !showonce)
{
cout << "\nYou made $1000 in "
<< days << " days!" << endl;
showonce = 1;
}
}
cout << "You made $1000000 in " << days << " days!\n";
cout << "Remember to share with carebear! ^^\n";
return 0;
}