Question

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 “—1.5 times their hourly wage — for overtime hours worked )

USING C++

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 “—1.5 times their hourly wage — for overtime hours worked ), commission workers (who receive $250 plus 5.7 percent of their gross weekly sales), or pieceworkers (who receive a fixed amount of money per item for each of the items they produce). 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 code 1, hourly workers have code 2, commission workers have code 3, and pieceworkers have code 4. The program should prompt the user to enter a pay code and the appropriate facts your program needs to calculate each employee’s pay according to that employee’s pay code. The user enters -1 to end the program.

Sample run:

                  Payroll Program

1. Managers

2. Hourly workers

3. Commission workers

4. Pieceworkers

Enter pay code (-1 to end): 3


Commission worker selected.

Enter gross weekly sales: 300

Commission worker's pay is $267.10


Enter pay code (-1 to end): 4

Pieceworker selected.

Enter number of pieces: 100

Enter wage per piece: 35.70

Pieceworker's pay is $3570.00


Enter pay code (-1 to end): 1

Manager selected.

Enter weekly salary: 1500

The manager's pay is $1500.00


Enter pay code (-1 to end): 2

Hourly worker selected.

Enter the hourly salary: 25

Enter the total hours worked: 45

Worker's pay is $1187.50


Enter pay code (-1 to end): -1

Have a good day!

Submission Instruction:

• Submit your source file via Canvas by the beginning of the class on March 2, 2018.

• You only need to submit your source code file (.cpp).

Solutions

Expert Solution

Answer:

#include

using namespace std;

int main() /* start of main() function */

{

int choice,pieces; /* variable declaration */

double mgr_sal,hour_sal,hours,pay,week_sales,wage_piece; /* variable declaration */

cout<<" Payroll Program "<

cout<<"1.Managers"<

cout<<"2.Hourly workers"<

cout<<"3.Commission workers"<

cout<<"4.Pieceworkers"<

cout<<"Enter pay code (-1 to end):"; /*prompts the message */

cin>>choice; /* Accepts the integer from the keyboard and stores in the variable choice */

while(1) /* Infinite loop, will be terminated when user selects -1 as choice */

{

switch(choice) /* takes the value in choice, goes to respective case */

{

case 1:cout<<"Manager seleted."<

cout<<"Enter weekly salary:"; /*prompts the message */

cin>>mgr_sal; /* Accepts the value from the keyboard and stores in mgr_sal */

cout<<"The manager's pay is $"<

break; /* Terminated from switch */

case 2:cout<<"Hourly worker selected."<

cout<<"Enter the hourly salary:"; /*prompts the message */

cin>>hour_sal; /* Accepts the value from the keyboard and stores in hour_sal */

cout<<"Enter the total hours worked:"; /*prompts the message */

cin>>hours; /* Accepts the value from the keyboard and stores in hours */

if(hours<=40&&hours>0) /* if the hours value is in between 0 and 40 */

pay=hours*hour_sal; /* calculates the pay using this formula */

else if(hours>40) /* If the hours value is greater than 40 */

pay=(hours-40)*(hour_sal*1.5)+(40*hour_sal); /* calculates the pay using this formula */

cout<<"Worker's pay is $"<

break; /* Terminated from switch */

case 3:cout<<"Commission worker selected."<

cout<<"Enter gross weekly sales:"; /*prompts the message */

cin>>week_sales; /* Accepts the value from the keyboard and stores in week_sales */

pay=250+((week_sales*5.7)/100); /* calculates pay using this formula */

cout<<"Commission worker's pay is $"<

break; /* Terminated from switch */

case 4:cout<<"piece worker selected."<

cout<<"Enter number of pieces:"; /*prompts the message */

cin>>pieces; /* Accepts the value from the keyboard and stores in pieces */

cout<<"Enter wage per piece:"; /*prompts the message */

cin>>wage_piece; /* Accepts the value from the keyboard and stores in wage_piece */

pay=pieces*wage_piece; /* calculates pay using this formula */

cout<<"Pieceworker's pay is $"<

break; /* Terminated from switch */

case -1:cout<<"Have a good day!"; /*prompts the message */

exit(0); /* Exited from the Infinite loop */

default:cout<<"Invalid choice, please enter correct choice"; /*prompts the message */

} /* End of switch */

cout<

cin>>choice; /* Accepts the value from keyboard and stores in the variable choice */

} /* End of the loop */

return 0;

} /* End of main() function */

Output:


Related Solutions

Problem Description 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
Programming Language: C++Problem Description 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...
A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who...
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 for each of the items they produce—each pieceworker in this company works on only one type of item). Write...
A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who...
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...
Many universities pay their teaching assistants (TA) or associate instructors (AI) as weekly workers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 10 hours they work and “time-and-a-half”
Needs to be written in CMany universities pay their teaching assistants (TA) or associate instructors (AI) as weekly workers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 10 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 7.1 times their gross weekly work hours), or pieceworkers (who receive a fixed amount of money for each of...
A company pays its employees as managers (who receive a fixed weekly salary)
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...
A company pays its employees as managers (who receive a fixed weekly salary)
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 for each of the items they produce—each pieceworker in this company works on only one type of item). Write...
A company pays its employees as managers (who receive a fixedweekly salary), hourly workers (who...
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...
Decor Paints pays regular hourly rates for the first 40 hours worked and time and a...
Decor Paints pays regular hourly rates for the first 40 hours worked and time and a half thereafter. The weekly payroll record shown below gives the total hours worked and hourly rates for the three employees. Fill in the remaining information including totals.​ ​ Payroll Record DECOR PAINTS Weekly Payroll Week Ending April 8, 20___ ​ ​ ​ Regular Earnings ​ Overtime Earnings ​ ​ Total Hours Rate/ ​ Hours Rate/ ​ Total Name Hours Worked Hour Amount Worked Hour...
An employee receives an hourly wage rate of $16, with time-and-a-half for all hours worked in excess of 40 during the week.
An employee receives an hourly wage rate of $16, with time-and-a-half for all hours worked in excess of 40 during the week. Payroll data for the current week are as follows: hours worked, 47; federal income tax withheld, $145; social security tax rate, 6.0%; Medicare tax rate, 1.5%; state unemployment compensation tax, 3.4% on the first $7,000; and federal unemployment compensation tax, 0.8% on the first $7,000. What is the net amount to be paid to the employee? Round your...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT