wages with overtime_pay and triple_pay

hello I am doing an assignment for a class that involves using wages i have to Write a program that computes an employees pay Monthly (4 weeks). The
program should input the number of hours worked in a week and the pay rate per
hour. Any hours that are over 40 and less than or equal to 60 will be computed
using (1.75 * pay rate). Any hours over 60 will be computed using (3 * payrate).
The output of the program should be regular pay, overtime pay, Triple pay and
total pay. Regular pay is the pay received for the first 40 hours. I also have to use if-else statements but i cannot figure it out the triple pay prints but not the regular pay or overtime pay. also i cannot figure out how to limit the overtime pay to no more than 20 hours.

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
  #include<iostream>
using namespace std;

int main()
{
	int hours;
	double payrate, totalhours, regularpay, overtimepay, triplepay, weeklypay,monthlypay;
	cout << "enter your total hours in a week\n";
	cin >> hours;
	cout << "enter your payrate\n";
	cin >> payrate;

	if (hours <= 40) {
		regularpay = hours*payrate;
	}
	else if (hours>40 && hours <= 60) {
		overtimepay = (hours - 40)*(payrate*1.75);
		}
	else (hours > 60); {
		triplepay = (hours - 40)*(payrate * 3);
		}
	cout << regularpay << endl;
	cout << overtimepay << endl;
	cout << triplepay << endl;
	weeklypay = regularpay + overtimepay + triplepay;
	cout << weeklypay << endl;
	monthlypay = weeklypay * 4;
	cout << monthlypay;

}
1
2
3
4
5
6
7
8
9
    if ( hours > 40 ) regularpay = 40 * payrate;
    else regularpay = hours * payrate;
    hours -= 40;    // get rid of the hours we've figured pay for.

    if ( hours > 20 ) overtimepay = 20 * payrate * 1.75;
    else overtimepay = hours * payrate * 1.75;
    // adjust hours.

    // handle triple time.. 

Topic archived. No new replies allowed.