// file: PayrollFunctions.cpp
// Computes and displays gross pay and net pay given an hourly
// rate and number of hours worked. Deducts union deus of $15
// if gross salary exceeds $100; otherwise,deducts no dues.
#include <iostream>
using namespace std;
// Functions used...
void instructUser();
float computeGross (float, float);
float computeNet (money);
const float MAX_NO_DUES = 100.00;
const float dues = 15.00;
const float MAX_NO_OVERTIME = 40.0;
const float OVERTIME_RATE = 1.5;
int main()
{
float hours;
float rate;
float gross;
float net;
// Display user instructions
instructUser();
//Enter hours and rate
cout<< "hours worked: ";
cin>> hours;
cout<< " Hourly rate: $";
cin>>rate;
// Compute gorss salary
gross = computeGross (hours,rate );
// Compute net salary
net = computeNet(gross);
// Print gross and net.
cout << " Gross salary is $" << gross<<endl;
cout<< "net salary is $<, net<<endl;
return 0;
}
// Display user instructions
void instructUser()
{
cout << "This program compute 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<< "times the regualr rate fro hours worked over "<< MAX_NO_OVERTIME endl << endl;
cout << "on separate lines after the promts. " <<endl;
cout << " Press <return > after typing each number . " << endl << endl;
}
// Find the gross pay
float compueGross
(float hours,float rate)
{
// Local data . . .
float gross; // result : gross pay (dollars)
float regularPay; // pay for first 40 hours
float overtimePay; // pay for hours in excess of 40
// Compute gross pay.
if ( hours > MAX_NO_OVERTIME)
{
regularPay= MAX_NO_OVERTIME *rate;
overtimePay = (hours - MAX_NO_OVERTIME) * OVERTIME_RATE *rate;
fross = regularPay +overtimeay;
else
gross = hours * rate;
return gross;
} // end computeGross
// Find the net pay
float computeNet
(float gross)
{
//Local data...
float net;
// Compute net pay.
duesif (gross> MAX_NO_DUES)
net =gross - DUES // deduct dues amount
else
net = gross;
return net;
}//end computeNet
I don't know why when I compile the program, it has the error in the " money ", this program I copied from text book to practice, so I am confused now,
Please explain me more about the function and argument,... thank you