PLEASE HELP!!

I have a project due at midnight tonight that I cannot figure out. I need to write a program that will calculate a user's salary if their pay starts at a penny and doubles every day from then on for up to a month. I cannot figure out what formula to write to get my pay amounts to calculate and I do not know how to total them all up either. Please please help! This is the code I have so far.

#include <iostream>
#include <iomanip>

using namespace std;

#define MAX_DAYS 30
#define MIN_DAYS 1
#define START_PAY .01

int main()

{

int days, count;
double payAmount, total;

cout<<"How many days will you be working (1-30)? ";
cin>>days;
cout<<endl;

while (days < MIN_DAYS || days > MAX_DAYS)
{
cout<<"Error: the number of days must be between 1 and 30. Try again: ";
cin>>days;
cout<<endl;
}

cout<< "Days Pay Amount"<<endl;
cout<< "-----------------------------"<<endl;


for (count=1; count>=MIN_DAYS&&count<=MAX_DAYS; count++)
{

cout<<setw(2)<<count<<setw(22)<<payAmount<<endl;

}

return 0;
}

Well then.... might as well help you out. lol I messed up your code and got this. If you don't see this by midnight, then its not my fault. Stay awesome Gotham!

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
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

#define MAX_DAYS 30
#define MIN_DAYS 1
#define START_PAY .01

int main()

{

	int days, count;
	double payAmount = 0, total;

	cout << "How many days will you be working (1-30)? ";
	cin >> days;
	cout << endl;

	while (days < MIN_DAYS || days > MAX_DAYS)
	{
		cout << "Error: the number of days must be between 1 and 30. Try again: ";
		cin >> days;
		cout << endl;
	}

	cout << "Days Pay Amount" << endl;
	cout << "-----------------------------" << endl;


	for (count = 1; count <= days; count ++ )
	{
		cout << fixed << showpoint << setprecision(2);
		total = START_PAY * 2;
		payAmount += total;
		cout << payAmount << " ";
		

	}
	_getch();
	return 0;
}
@titevi3boi

Sorry, but your solution is not correct. The salary is doubled each day, so day 1 would be .01, day 2, .02 cents, day 3 is .04 cents and so on. The correct way is...

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
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

#define MAX_DAYS 30
#define MIN_DAYS 1
#define START_PAY .01

int main()

{

	int days, count;
	double payAmount = START_PAY, total = START_PAY;

	cout << "How many days will you be working (1-30)? ";
	cin >> days;
	cout << endl;

	while (days < MIN_DAYS || days > MAX_DAYS)
	{
		cout << "Error: the number of days must be between 1 and 30. Try again: ";
		cin >> days;
		cout << endl;
	}

	cout << "Days \tPay \tAmount" << endl;
	cout << "-----------------------------" << endl;


	for (count = 0; count < days; count++)
	{
		cout << fixed << showpoint << setprecision(2);
		cout << "Pay on day " << count+1 << " is $" << payAmount << " " << endl;
		
		if (count < days-1)
		{
			payAmount *= 2; 
			total += payAmount;
		}
	}
	cout << endl << "Total pay for " << days << " days of work is $" << total << " " << endl;
	_getch();
	return 0;
}
Last edited on
Topic archived. No new replies allowed.