Payroll
đ Background Information
This problem is available courtesy of (James).
đŻ Problem Statement
Create a payroll calculator for an employee of a business. When an employee enters their hours worked and number of dependents, the program will give them a full breakdown of their expenses and net pay.
â Acceptance Criteria
- When I start the program, I should see a welcome message.
- Next, the program should prompt me for the number of hours I worked this week and the number of dependents I have.
- From that information, the program should print out a report with my hours worked, rate of pay, gross earnings, calculated expenses, and net pay.
- Finally, the program should print an goodbye message and exit gracefully.
The following information will be useful when creating the report:
-
The current hourly rate is $16.78 per hour for all employees. This rate is paid for an employeeâs first 40 hours worked each week. If the employee works overtime (i.e. works hours beyond the first 40), those hours are paid at a rate one and a half times the normal pay rate.
-
Gross pay is calculated by taking the hourly rate and multiplying it by the number of hours worked. Donât forget to take overtime into account.
-
Tax 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 which takes $10.00 for union dues.
-
Employees participate in a group insurance program so that they can get good rates on health insurance. The current package says that workers with three or more dependents must pay $35 per pay check whereas other employees need to pay $15 per paycheck.
-
Net pay is equal to gross pay minus all of the expenses. Note that net pay might be a negative number - we will fix that issue in one of the Add-Ons for the Portfolio.
đ Dev Notes
-
Your output does not need to look exactly like the example output below. However, your output should be neat and organized with some formatting to the output. Dollar amounts should be aligned by either the decimal place or by the dollar sign. The entries in the report should either be left or right justified to make the report look nice and neat.
-
There is a lot of business logic happening in this lab. Try to split each calculation in the payroll into a separate method with its own tests.
đĽď¸ Example Output
Your output report does not have to match this format exactly. I simply want to see all of the relevant information in a well-organized report. This includes the hours worked, payrate, gross pay, expenses, and net pay. An example output is as follows:
$ gradle run
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 Payroll Program!
đ Thought Provoking Questions
- What was your testing strategy for this lab? When were you able to use JUnit versus when did you have to do manual testing?
đź Add-Ons For the Portfolio
(One Credit) Customized Pay Rate
It is unrealistic for every employee of the company to earn $16.78 per hour. Add a prompt to ask the user what their pay rate is. Then, use that pay rate in all of the calculations.
The output of your program should not change otherwise.
(One Credit) Validations for Pay Rate
You must first complete the add-on called âCustomized Pay Rateâ before you can attempt this add-on.
Right now, an employee can accidentally type a negative number for the pay rate. Update your code so that if an employee types a negative number for the pay rate, it asks them to re-enter their rate of pay.
The output of your program should not change otherwise.
(One Credit) Validations for Number of Children
Right now, an employee can accidentally type a negative number for the number of children. Update your code so that if an employee types a negative number for the number of children, it automatically treats the number of children as zero. Is this the best strategy? Probably not. But the employee will see zero children on their report and know something went wrong.
The output of your program should not change otherwise.
(Two Credits) Validations for Negative Pay
After taxes are deducted from an employeeâs paycheck, there could be a situation where there is not enough money left for union dues or insurance payments. In this situation, donât subtract union dues or insurance payments from the paycheck. Instead, print out how much the employee owes in dues / payments in addition to their payment. An example output looks like:
$ gradle run
Welcome to the Payroll Program!
How many hours did you work this week? 2
How many children do you have? 4
Payroll Stub:
Hours: 2.0
Rate: 16.78 $/hr
Gross: $ 33.56
SocSec: $ 2.01
FedTax: $ 4.70
StTax: $ 1.68
Net: $ 25.17
The employee still owes:
Union: $ 10.00
Ins: $ 35.00
Thank you for using the Payroll Program!
(Four Credits) Life Insurance Plans
Employees can now add a life insurance plan to their payroll calculation. The packages available are: (1) no plan, (2) the single plan, (3) the married plan, and (4) the married with children plan. In addition to prompting the user for the number of hours that they worked and the number of children that they have, prompt the user with a menu of life insurance options. If the user enters a valid life insurance option, proceed with the calculation, including the life insurance costs outlined below. If the user does not enter a valid life insurance plan, print out an error message and prompt them for another selection.
-
Any employee can select the âno planâ option. In that case, there is no additional deduction from their paycheck.
-
Any employee can select the âsingle planâ option. In that case, there is a $5 deduction from their paycheck.
-
Any employee can select the âmarried planâ option (we will assume for now that everyone is perfectly honest about reporting whether they are married or not). In that case, there is a $10 deduction from their paycheck.
-
Only employees with one or more children can select the âmarried with childrenâ plan. In that case, there is a $15 deduction from their paycheck.
An example output is shown below:
$ gradle run
Welcome to the Payroll Program!
How many hours did you work this week? 30
How many children do you have? 0
Which life insurance plan do you want to select?
(1) no plan
(2) single plan
(3) married plan
(4) married with children plan
4
Sorry! You need at least one child to select that plan.
Which life insurance plan do you want to select?
(1) no plan
(2) single plan
(3) married plan
(4) married with children plan
2
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: $ 15.00
LifeIns: $ 5.00
Net: $ 347.55
Thank you for using the Payroll Program!
đ Works Cited
- James, Jason. âPayrollârâUs.â Jason Jamesâ Homepage, http://craie-programming.org/121/labs/payroll.html, July 2018.