Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that has four functions that do the following: A main() function

ID: 3761152 • Letter: W

Question

Write a program that has four functions that do the following: A main() function that has a loop 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.

Explanation / Answer

#include<iostream>

#include<string.h>

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 "<<name<<" in this pay period is $"<<pay<<" ";

}

int main() {

string name;

float hours, payRate;

char ch;

  

do {

inputData(name, hours, payRate);

float pay = computePay(hours, payRate);

displayPay(name, pay);

  

cout<<" Do you need more payroll calculations? (y/n)";

cin>>ch;

cout<<" ";

} while (ch != 'n');

  

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote