In: Computer Science
A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and “time-and-a-half,” i.e. 1.5 times their hourly wage, for overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money per item for each of the items they produce-each pieceworker in this company works on only one type of item). Write a program to compute the weekly pay for each employee. You do not know the number of employees in advance. Each type of employee has its own pay code: Managers have pay code 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a switch to compute each employee’s pay based on that employee’s paycode. Within the switch, prompt the user to enter the appropriate facts your program needs to calculate each employee’s pay based on that employee’s paycode.
/*Copyable Code*/
#include
#include
#include
using namespace std;
void manager_pay_code();
void hourly_workers_pay_code();
void commision_workers_pay_code();
void piece_workers_pay_code();
/* Main Function that accepts input from user regarding paycode
and executes corresponding function */
int main()
{
int paycode;
int managers=0, hourly_workers=0, piece_workers=0,
commision_workers=0;
cout<< endl << endl << "Enter Paycode (-1 to
end): " ;
cin>>paycode;
while(paycode != -1)
{
switch(paycode)
{
case 1: manager_pay_code(); //Calls Manager Paycode Function
managers++;
break;
case 2: hourly_workers_pay_code(); //Calls Hourly Workers
Function
hourly_workers++;
break;
case 3: commision_workers_pay_code(); //Calls Commission Workers
Function
commision_workers++;
break;
case 4: piece_workers_pay_code(); //Calls Piece Workers
Function
piece_workers++;
break;
default: cout<<"Invalid Choice";
break;
}
cout<< endl << endl << "Enter Paycode (-1 to
end): " ; getch(); //Manager Function //Hourly Workers Function //Manager Function
cin>>paycode;
}
//Printing Payout Statistics
cout<
return 0;
}
//Input: None
//OutPut: None
//Operation: Accept salary and prints the same as final
salary
void manager_pay_code()
{
float final_pay;
cout<< endl <<"Manager selected.";
cout<
cout<< endl <<"Manager pay is $" <<
final_pay;
}
//Input: None
//OutPut: None
//Operation: Accepts hourly salary and hours worked and calculate
final salary and print final salary
void hourly_workers_pay_code()
{
float hourly_salary;
int hours_worked, actual_hours, ot_hours;
float final_pay;
cout<< endl <<"Hourly worker is selected.";
cout<
cout<
//Code that divides actual hours and overtime(ot) hours
if(hours_worked > 40)
{
actual_hours = 40;
ot_hours = hours_worked - 40;
}
else
{
actual_hours = hours_worked;
ot_hours = 0;
}
final_pay = (actual_hours * hourly_salary) + (1.5 * (ot_hours *
hourly_salary));
cout<< endl <<"Hourly worker pay is $" <<
final_pay;
}
//Input: None
//OutPut: None
//Operation: Accept gross weekly sales and calculates the final
salary an prints final salary
void commision_workers_pay_code()
{
int gross_weekly_sales;
float final_pay;
cout<< endl <<"Commission worker selected.";
cout<
final_pay = 250 + ((5.7*gross_weekly_sales)/100);
cout<< endl <<"Commission worker's pay is $" <<
final_pay;
}
//Manager Function
//Input: None
//OutPut: None
//Operation: Accept price per item and number of items and
calculate final pay and prints final pay
void piece_workers_pay_code()
{
int no_of_items;
float final_pay, price_per_item;
cout<< endl <<"Piece worker selected.";
cout<
cout<
final_pay = no_of_items * price_per_item;
cout<< endl <<"Piece worker pay is $" <<
final_pay;
}