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

A company pays its employees as managers (who receive a fixed weekly salary), ho

ID: 3661911 • Letter: A

Question

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 C++ 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.

SampleOutput

Enter paycode (-1 to end): 3

Commission worker selected.

Enter gross weekly sales: 4000

Commission worker’s pay is $ 478.00

Enter paycode (-1 to end): 2

Hourly worker is selected.

Enter hourly salary: 4.5

Enter the total hours worked: 20

Worker’s pay is $90.00

Enter paycode (-1 to end): -1

Summary of Payouts

Employee Categories Number Paid

—————————— —————–

Managers 0

Hourly Workers 1

Commission Workers 0

Piece Workers 0

Explanation / Answer

Program :

# include<iostream>
using namespace std;
int main(){
   int ch,hours,ex,gsales,p,weeks;//declaring integer data types
   double hsalary,hpay,cpay,pitem,wsalary,mpay,ppay;//declaring double data types
   do{//do while loop
   cout<<"Enter paycode (-1 to end): ";
   cin>>ch;//taking user input choice
   switch(ch){ //switch statement with several cases
       case 1://case 1 is about managers pay
           cout<<"Manager selected"<<endl;
           cout<<"Enter the salary per week";
           cin>>wsalary;
           cout<<"Enter no. of weeks worked :";
           cin>>weeks;
           mpay=weeks*wsalary;
           cout<<"Manger pay is $"<<mpay<<endl;
           break;
       case 2://case 2 is about hourly worker salary
           cout<<"Hourly worker is selected"<<endl;
           cout<<"Enter Hourly salary :";
           cin>>hsalary;
           cout<<"Enter the total hours worked :";
           cin>>hours;
           if(hours>40){ //if statement that checks the hours greter than the 40 hrs
               ex=hours-40;
               hpay=40*hsalary;
               hpay+=(ex*((1.5/100)*hours));//add 1.5 times extra for over time workers
               cout<<"Hourly worker pay is $"<<hpay;
           }else{
               hpay=hsalary*hours;
               cout<<"Hourly worker pay is $"<<hpay<<endl;
           }
           break;
       case 3://case 3 is about comission worker pay
           cout<<"Commission worker selected"<<endl;
           cout<<"Enter gross weekly sales:";
           cin>>gsales;
           cpay=((gsales/100)*5.7)+250;
           cout<<"commision workers pay is $"<<cpay<<endl;
           break;
       case 4:// case 4 is about piece worker pay
           cout<<"Piece worker selected";
           cout<<"Enter the amount per item :";
           cin>>pitem;
           cout<<"Enter the number of items produced :";
           cin>>p;
           ppay=p*pitem;
           cout<<"Piece worker pay is $"<<ppay<<endl;
           break;
       default :
           cout<<"thanks";
   }
}while(ch!=-1);//while loop
}

Expected Output :

Enter paycode (-1 to end): 3
Commission worker selected
Enter gross weekly sales:4000
commision workers pay is $478
Enter paycode (-1 to end): 2
Hourly worker is selected
Enter Hourly salary :4.5
Enter the total hours worked :20
Hourly worker pay is $90
Enter paycode (-1 to end): -1
thanks
--------------------------------
Process exited with return value 0
Press any key to continue . . .

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