How do i compute this?

how do i say i want to compute to find the base pay, overtime pay, and gross 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
//Prince Akhtar CSE 110 - Lab # 1
//This program computes payroll using hours and pay rate
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int hoursWorked;
    double hourlyRate, grossPay;

    cout << "Enter the hourly rate of pay; $";
    cin >> hourlyRate;
    cout << "Enter the number of hours worked, " <<endl;
    cout << "rounded to a whole number  of hours:";
    cin >> hoursWorked;

        grossPay = hourlyRate * hoursWorked;//calculate gross pay

        cout << fixed << setprecision(2);

        cout << "Hours worked = " << hoursWorked << endl;
        cout << "Hourly pay rate = $" << hourlyRate << endl;
        cout << "Gross pay = $" << grossPay << endl;

    return 0;
Last edited on
hourlyWage ^ hoursWorked
This makes no sense at all. What is this trying to do?



Your if blocks need to be inside braces ( i.e. inside { and } )
sorry wrong one, the other one was me trying to figure it out
typically this is going to be
gross = base pay + (hoursworked-8)*overtimerate
where 8 is a normal day, and anything more is overtime...
so a normal 8 hour day is just base-pay + zero

alternately for hourly wages its
gross = (max(8, worked) * baserate) + (worked-8)*overtimerate;
which accounts for say a 4 hour day.

Topic archived. No new replies allowed.