that calls the other three functions until a user enters ‘n’ in response to the question, “Do you
need more payroll calculations? (y/n) ” An inputData() function to input employee name, hours
worked and pay rate A computePay() function to calculate the amount to be paid based on the
formula: For the first 40 hours, the rate is the given rate; For hours over 40, the rate is 1.5 times
the given rate An displayPay() function to output the name and the amount to be paid. Example:
The amount to be paid to John Doe in this pay period is $754.80 Write a statement at the bottom
of the program to call the main() function.
Solution
#include
#include
using namespace std;
void inputData(string &name, float &hours, float &payRate) {
cout<<\"Enter name: \";
cin>>name;
cout<<\"Enter hours worked: \";
cin>>hours;
cout<<\"Enter pay rate: \";
cin>>payRate;
}
float computePay(float hours, float payRate) {
float pay;
if (hours >= 40) {
pay = hours*payRate;
} else {
pay = hours*payRate*1.5;
}
return pay;
}
void displayPay(string name, float pay) {
cout<<\"The amount to be paid to \"<>ch;
cout<<\"\ \ \";