[code]#include <iostream>
usingnamespace std;
/*
Program calculates the salary of a person over a period of time. Program asks user for number of days.
Program displays a table showing the salary for each day and the accumulated pay for each day.
*/
void main()
{
int day;
int penny = 1;
double total = 0.01;
int count;
while (true)
{
for (day = 1; penny <= day; day++)
{
penny = penny * 2;
total = penny*0.01;
}
cout << "Day Earning that day (pennies) Total earnings for that day (dollars)" << endl;
cout << day << " " << penny << " " << total << endl;
}
}[code]
The loop at line 17 will never exit. What is its purpose? Right now the loop at line 19 will run for the some number of days, then the loop at line 17 will run and do it all over again.
At line 19, days is uninitialized. How many days should the loop run for?
Line 22. This says that the pay doubles every day. Is that your intention?
Line 24 converts the pennies to dollars, but it doesn't accumulate the total from the previous days. I think you want to initialize total to 0 at line 14 and then line 24 should add pennies*0.01 to total.