Assignment
- Rewriting the payroll to include two new methods
1) tax bracket calculation.
2) gather the manager and years entries and calculate
base pay.
You should have already written a payroll program. The original
instructions were: click here
You then rewrote it to include a method that prints all the instructions in advance. click here
1) Extract the tax bracket if statement from the main body, and place it in
a new method. That method takes in a gross pay amount (double) and returns a
tax percentage (double). It should not do any printing, so if you had
embedded the printing inside the if statement, you will need to remove it. You
may need to adjust your main program to work properly after it calls the tax
rate determination program.
Create a test method that verifies that all the border and extreme cases
work.
2) Extract the inputting of the manager question and the years and then
calculating the base pay into one method. If your program didn't work in this
order, you will need to change your main program flow. This new rate
calculation will take in nothing () and will return the base pay (double), which
includes manager or employee pay and the years. Only the method needs the
Constants relating to manager and regular pay, and the inputted manager
question and rate. Be sure to remove these variables from the main program and
bury them inside the method instead.
1. getTaxRate
Input parameters: |
||||||||||||
|
Double |
Gross Pay |
||||||||||
Description of processing: Set the tax rate according to the following table:
|
||||||||||||
Return: |
||||||||||||
|
Double |
Tax Rate |
Be sure to create a test case method for this one also.
2. getPayRate
Input parameters: |
||
|
|
no input parameters |
Description of processing: Ask the user whether they are a manager and the number of years worked. Use both those (and not hours worked) to calculate the base pay. Managers get $15 / hour and everyone else gets $10 / hour. They get $1 per hour more for each year of service. (Example: If a manager had worked at the company for 10 years, she would earn $25 / hour.) |
||
Return: |
||
|
Double |
Base Pay |