This program is to help you in working with branches (mainly ifs). while continuing to hone your skills with main program design, variables and data types, and arithmetic. (There are opportunities for using standard library functions, advanced branching and looping practice, as well.)
We here at Payroll'r'Us feel strongly that our company's service of printing payroll stubs for our clients' employees is a number one priority. That's why we are putting you in charge.
The client you'll be creating payroll stubs for (a manufacturer of fine Star Trek fan memorabilia) currently has only one salary rate for all of their employees. (But they hope that they'll soon be diversifying their line and so we shouldn't count on there always being only one salary rate!)
The current rate is 16.78 $/hour. This rate is paid for an employee's first 40 hours worked each week. If the employee is working overtime (hours beyond the first 40), those hours are paid at a rate one and a half times the normal pay rate.
Deductions from employees' pay include 6% withheld for social security tax, 14% withheld for federal income tax, and 5% withheld for state income tax. All employees are also a part of the local union and as such, $10.00 is withheld from each check for union dues.
Our client also participates in a group insurance program so that their employees can get good rates on health insurance. The current package says that workers with three or more dependents must pay $35.00 per pay check in addition to the employer's contribution. Other employees need not pay any additional insurance.
Each pay-stub should include information about the worker's hours worked for that period, their rate of pay, their gross earnings, all of the deductions that apply (you don't have to print $0.00 for employees who have less than three dependents, for instance), and the resulting net pay after all deductions are...well...deducted.
As an example, you might have the program interaction look something like (the parts in this color are typed by the user):
$ ./payroll.out Welcome to the Payroll Program!!! How many hours did you work this week? 30 How many children do you have? 4 Payroll Stub: Hours: 30.0 Rate: 16.78 $/hr Gross: $503.40 SocSec: $ 30.20 FedTax: $ 70.48 StTax: $ 25.17 Union: $ 10.00 Ins: $ 35.00 Net: $332.55 Thank you for using the PP!! Endeavor to have a StarTrek-esque day! $
(Your display need not come out as neatly as mine. I'm just a little obsessive. But if you'd like it that way too, we've discussed this to some extent elsewhere on the site. In fact, I'll give you extra levels to do so...)
This assignment is (Level 2).
If you make your answers come out all pretty like I did mine, you can earn an extra (Level 2). This requires not only that all your dollar amounts line up but also that they all have proper numbers of decimal places — including trailing zeros! (Also note that the hours value is printed with a single decimal place.)
One of the Vice Presidents has decided that hourly workers should be paid only for complete 15-minute work periods. Therefore you need to round down the entered hours to the next lowest quarter hour before calculating everything. Doing this is worth an extra (Level 1) — despite being a violation of several federal regulations on how workers should be treated.
Note that, if you've done the pretty-printing option above, this one would require you to change the hours to display to 2 decimal places rather than just 1.
The secretary of the head comptroller (the person in charge of payroll) is annoyed that he has to keep running the program over and over to generate the stubs for all of the employees.
Add (Level 1) to make your program repeat the data entry and stub report again and again and again ... until the user indicates that they would like to stop. (Hint: *ahem* Yes/No loop... *ahem*)
In fact, you can add another (Level 0.5) to total up the various pay-stub monetary categories over the several employees that are reported on during the run.
From time to time, an employee will return to the comptroller's office to complain that they are being paid negative XXX dollars! Others have been overheard in the break room, cackling with glee that they didn't have to pay insurance on their -5 children!
Add (Level 1) to do error/domain checking on the user's input of hours and number of children (neither should be negative; either can be 0 or positive).
The comptroller has noticed that when her secretary is ill and a temp is generating the stubs, that she hears many more complaints than normal. It seems that when the agency sends over the temp, no one gets any pay that period. In fact, they all simply owe the union $10.00 and so their checks come out negative!
After looking over the temp's shoulder the other day, the reason for the complaints has become clear: the temp only types in words so an employee who's worked 50.5 hours is entered as 'fifty and a half' (without the tick/quote marks, of course).
Add (Level 1.5) to adjust your input validation loop to avoid failure when the user types a non-numeric character at your numeric prompts.
The insurance company has recently re-negotiated the group package that our client uses and the rates have changed. Unfortunately, our client can no longer afford to take on all of the employees' payments for under three dependents. The new scale is that single workers are to pay $5.00 per pay period, married workers with no dependents will pay $10.00 per pay period, married workers with less than three dependents will pay $20.00 per pay period, and married workers with three or more dependents will still pay $35.00 per pay period. (The insurance company, it seems, has not caught on that this is the 21st century and that people don't have to be married to have dependents. *shrug* C'est la vie..!)
Add (Level 2) for adding a packaged insurance program. The packages available are the single plan, the married plan, and the married with children plan (with the 2 child deductible mentioned above). You should offer the user a menu of insurance packages:
1) Single 2) Married 3) married with Children
Don't let the user by without choosing a valid option here. Allow them to enter an option by either the number or the capitalized letter. (So they can choose the married package by entering either '2', 'M', or 'm'.)
Remember: Single folks have a $5.00 per-check payment. Married people must pay $10.00 per paycheck. And those with children pay depending on how many children they have. Less than 3 children makes them pay $20.00 while 3 or more makes them pay $35.00. (Careful: You'll only need to ask them how many children they have when they choose the married with children option!)
A switch is the preferred branching structure for menu situations such as this, of course. In fact, if you use a switch to make the decision as to what menu option was/not chosen, you can add an extra (Level 1).
The longer your main program becomes, the more difficult it becomes to maintain and adjust. This (and other problems) is taken care of by simply using the idea of functions and top-down design principles! By modularizing the program, we not only reduce the size and complexity of the main, but we may also eliminate bugs, be able to re-use one function for two separate tasks, and even make the whole program more readable and manageable.
Add (Level 3) to use functions to break up your program into more manageable pieces instead of having lots of redundant code in a long, long, long main program.
If you did all above options, this lab could be worth as much as (Level 14).