I'm trying to write a program which allows a person to enter the number of days they have worked. Their hypothetical salary is 0.01$ per day and doubles everyday (0.02$ on the 2nd and 0.04$ on the 3rd day etc...). For each day, the day number, pay for the day, and accumulated total pay has to appear. An example below:

Enter number of days: 3

Day-----Pay--- total pay

1------ 0.01----0.01

2------0.02----0.03

3------0.04----0.07

4------0.08----0.15

The program works, but I'm having difficulty with total pay. I'm not sure if its the math, or the structure it is written.

Where have I gone wrong?

I've gotten this so far:

int main ()

{

int x, days, ndays;

cout << " Enter number of days: " << endl;

cin >> ndays;

cout << endl;

double pay ;

double total_pay = 0.01 ;

cout << left << setw(15) << " DAY "

<< right << setw(10) << " PAY "

<< setw(15) << " TOTAL PAY " << endl;

for (days = 1, pay = 0.01; days <= ndays; days ++, pay *= 2)

if (total_pay += pay * 2) /* how do I get it to start on 0.01?*/

cout << left << setw(15) << days

<< right << setw(10) << pay

<< setw(15) << total_pay << endl;

system ("PAUSE");

return 0;

} // end of for loop