The We-Say-So Corporation needs a program to calculate how much to pay their hou
ID: 675017 • Letter: T
Question
The We-Say-So Corporation needs a program to calculate how much to pay their hourly employees. US labor laws state that hourly employees should be paid time and a half for any hours over 40 that they work in a single week. So, for example, if an employee works for 46 hours in a week, then they get 6 hours of overtime, at 1.5 times their base pay. The We-Say-So Corp. is based in a state where the minimum wage is 5.25 dollars per hour. It is company policy that employees should not work for more than 60 hours in a single week.
a) Write a method called salaryTotal that takes two inputs: the base pay and hours worked in a week as parameters, ane either returns the total pay, -1 if base pays is less than minimum wage, or -2 if number of hours worked is more than 60.
b) Also, write a main method that asks the user to input the full name, the base pay, and the hours worked in a week for a particular employee using the keyboard (separated by commas and in this order). main should use salaryTotal to compute the total pay for that employee and then print the following message to the screen:
The total pay for <full name> is <total pay> dollars.
Explanation / Answer
The complete program:
Sample output:
Code to Copy:
#include<iostream>
#include<string>
using namespace std;
int salaryTotal(int,int);
//main function
int main ()
{
string fullname;
int basepay;
int hoursworked;
cout<<"Enter the employee full name:";
cin>>fullname;
cout<<"Enter the base pay of employee:";
cin>>basepay;
cout<<"Enter hours worked by the employee:";
cin>> hoursworked;
cout<<"The Total pay for"<<" "<<fullname<<" "<< "is"<<" "<< salaryTotal(basepay,hoursworked)<<" "<<"dollars"<<endl;
system("pause");
}
int salaryTotal(int b,int h)
{
int Totalpay;
if(b<5.25)
return -1;
if(h>60)
return -2;
else if(h>40)
Totalpay=((h-40)*(b/2)) + (h*b);
else
Totalpay= h*b;
return Totalpay;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.