Develop a C++ console application that calculates and displays gross pay amounts. The user will enter the number of hours an employee worked and his or her pay rate. The program should contain four value-returning functions: main, getHoursWorked, getPayRate, and calcGross. The main function should call each of the other three functions and then display the gross pay on the screen. When coding the calcGross function, you do not have to worry about overtime pay. You can assume that everyone works 40 or fewer hours per week. The hours worked and rate of pay may contain a decimal place. Use a sentinel value to end the program.
#include <iostream>
#include <iomanip>
using namespace std;
int getHoursWorked();
float calcGross(int numOfHours,float payRate);
float getPayRate();
int main(int argc, char *argv[])
{
int numOfHours;
float grossPay;
float payRate;
do{
numOfHours = getHoursWorked();
payRate = getPayRate();
grossPay = calcGross(numOfHours,payRate);
cout<<setprecision (2) << fixed <<"Gross pay: "<<grossPay<<"\n\n";
}while(numOfHours != -1);
return 0;
}
int getHoursWorked()
{
int numOfHours;
cout<<"Enter the number of hours the employee worked (-1 to end program): ";
cin>>numOfHours;
return numOfHours;
}
float getPayRate()
{
float payRate;
cout<<"Enter the pay rate of the employee: ";
cin>>payRate;
return payRate;
}
float calcGross(int numOfHours,float payRate)
{
return numOfHours*payRate;
}