Pennies for pay

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[code]#include <iostream>
using namespace 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]
[/code][/code]
Last edited on
boss just write down the program documment:
1)what is the input
2) formula for internal calculation;
3) output;

give an example
Why are you using pennies?
that's what my question said..
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.
Topic archived. No new replies allowed.