Problem Statement: A company pays its employees as follows:

PROBLEM 4.28 - ANALYSIS

Problem Statement:A company pays its employees as follows:
1) managers (fixed weekly salary)2) hourly workers (fixed hourly wage for up to the first forty hours they work and "time-and-a-half" i.e. 1.5 times their hourly wage, for overtime hours worked)
3) commission workers ($250 plus 5.7% of their gross weekly sales)
4) pieceworkers (fixed amount of money per item for each of the items they produce, each piece worker in this company works on only 1 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:
code 1: managers
code 2: hourly workers
code 3: commission workers
code 4: pieceworkers
There will be an undetermined number of entries into the payroll. Use a switch to compute each employee's pay based on that employee's pay code. Within the switch, prompt the user (i.e. the payroll clerk) to enter the appropriate facts your program needs to calculate each employee's pay based on that employee's pay code. Print each pay value and when done with the entries, print total amount of payroll.Sample Run:
Enter employee's number code (-1 to end): 2
Enter hourly worker's pay rate: 10
Enter the number of hours worked: 35
Weekly pay is: 350.00

Enter employee's number code (-1 to end): 2
Enter hourly worker's pay rate: 12.25
Enter the number of hours worked: 100
Weekly pay is: 1592.50

Enter employee's number code (-1 to end): 2
Enter hourly worker's pay rate: 10
Enter the number of hours worked: 40
Weekly pay is: 400.00

Enter employee's number code (-1 to end): 1
Enter the manager's pay rate: 576.90
Weekly pay is: 576.90

Enter employee's number code (-1 to end): 3
Enter commission employee's gross weekly sales: 1098.45
Weekly pay is: 312.61

Enter employee's number code (-1 to end): 4

Enter the number of pieces completed: 200
Enter the employee's per piece pay rate: .23
Weekly pay is: 46.00

Enter employee's number code (-1 to end): 8
You have entered an invalid code.

Enter employee's number code (-1 to end): 9
You have entered an invalid code.

Enter employee's number code (-1 to end): 4

Enter the number of pieces completed: 100
Enter the employee's per piece pay rate: 2.75
Weekly pay is: 275.00

Enter employee's number code (-1 to end): -1

The total payroll for the week is: 3553.01


INPUT VARIABLES

Description
Name
Data Type
Rationale
stores which type of employee to processcodeintthe code numbers are integers
used to store pay rate and employee's weekly paypayfloatdollars may be decimal values
for commission worker, stores how much money that is brought in from salessalesfloatdollars may be decimal values
for hourly workers, stores how many hours they workedhoursfloatwe want to be able to keep track of a decimal number of hours
for piece workers, stores how many pieces have been madepiecesintworkers may only count completed pieces

OUTPUT VARIABLES

Description
Name
Data Type
Rationale
running total of all employee paytotalfloatdollars may be decimal value



ALGORITHM

1. Declare and initialize variables
2. Prompt user to enter employee code, -1 to end entries
3. While the sentinel value -1 has not been entered
3.1 Calculate employee's pay based on pay code
3.1.1 Manager (pay code 1)
3.1.1.1 Prompt user for manager's pay rate
3.1.1.2 Print the weekly pay of the manager
3.1.1.3 Add manager's pay to total pay
3.1.2 Hourly Worker (pay code 2)
3.1.2.1 Prompt user for hourly worker's pay rate
3.1.2.2 Prompt user for number of hours worked
3.1.2.3 If hours worked is greater than 40
3.1.2.3.1 Calculate pay rate for first 40 hours, then calculate pay rate ("time-and-a-half") for hours worked over 40, and add these values together
3.1.2.4 Otherwise, calculate regular pay rate
3.1.2.5 Print the weekly pay for the employee
3.1.2.6 Add weekly pay to total pay
3.1.3 Commission employee (pay code 3)
3.1.3.1 Prompt user for employee's gross weekly sales
3.1.3.2 Calculate weekly pay for the employee
3.1.3.3 Print the weekly pay
3.1.3.4 Add pay to total
3.1.4 Pieceworker (pay code 4)
3.1.4.1 Prompt user for the number of pieces completed
3.1.4.2 Prompt user for per piece pay rate
3.1.4.3 Calculate weekly pay for the employee
3.1.4.4 Print the weekly pay
3.1.4.5 Add pay to total
3.1.5 If pay code is not valid print error message
3.2 Prompt user to enter employee code, -1 to end entries
4. Print the total pay for the week

SOLUTION

Comments

Popular posts from this blog

How to make this program ask for input again if invalid input is entered (in C programming)? [duplicate]

Questions are taken from "C: How to Program" by Deitel and Deitel.

Assignment to develop a non-scientific calculator using C Language-81998