Question
In C++ // Computes and displays gross pay and net pay // given an hourly rate and number of hours // worked. Deducts union dues
In C++
// Computes and displays gross pay and net pay
// given an hourly rate and number of hours
// worked. Deducts union dues of $15 if gross
// salary exceeds $100; otherwise, deducts no dues.
The output should be like this:
This program computes gross and net salary.
A dues amount of $15.00 is deducted for an
employee who earns more than $100.00
Overtime is paid at the rate of 1.5 times the
regular rate on hours worked over 40
Enter hours worked and hourly rate on separate
lines after the prompts.
Press
Hours worked: 50
Hourly rate: 6 Gross salary is $330.00
Net salary is $315.00
-------------------------------------------------
This is my code
**// money.h //**
#include
using namespace std;
const money MAX_NO_DUES = 100.00; const money dues = 15.00; const float MAX_ON_OVERTIME = 40.0; const float OVERTIME_RATE = 1.5;
class money { private: float hours; float rate; public:
money(); money(float h, float r); void instructUser();
money computeGross(float, money); money computeNet(money);
};
**// money.cpp //**
#include "money.h"
money::money() { hours = 0.0; rate = 0.0; } money::money(float h, float r) { hours = h; rate = r; } void money::instructUser() { cout << "This program computes gross and net salary." << endl; cout << "A dues amount of" << dues << "is deducted for" << endl;
cout << "an employee who earns more than" << MAX_NO_DUES << endl << endl;
cout << "Overtime is paid at the rate of" << OVERTIME_RATE << endl;
cout << "Enter hours worked and hourly rate" << endl;
cout << "on separate lines after the prompts. " << endl; cout << "Press
money money::computeGross(float hours, money rate) { money gross; money regularPay; money overtimePay;
if(hours > MAX_ON_OVERTIME) { regularPay = MAX_ON_OVERTIME * rate; overtimePay = (hours - MAX_ON_OVERTIME) * OVERTIME_RATE * rate; gross = regularPay + overtimePay; } else { gross = hours * rate;
}
return gross; }
money money::computeNet(money gross) { money net;
if(gross > MAX_NO_DUES) { net = gross - dues; } else { net = gross; }
return net; }
**// moneyMain.cpp //**
#include
using namespace std;
int main() {
float hours; float rate; money gross; money net;
instructUser();
cout << "Hours worked: "; cin >> hours;
cout << "hourly rate: "; cin >> rate;
gross = computeGross(hours, rate);
net = computeNet(gross);
cout << "Gross salary is " << gross << endl; cout << "Net salary is " << net << endl;
return 0; }
Can anyone tell me what's wrong with it please
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started