This program assesses use of if logic, switch statement, NumberFormat class and working with characters and strings.
Question:
This program assesses use of if logic, switch statement, NumberFormat class and working with characters and strings. The user enters work data and a paycheck is produced.
Constants:
The program should use a named constant for state tax rate. Other named constants are optional.
Input:
The user enters a String full name in form (first last) with one blank separating the two pieces, integer number of dependents, and a char job code (H for Hourly, S for salaried). For hourly employees, the number of hours worked and hourly pay rate is entered. For salaried employees, the base salary is entered as salaried people earn the same amount each week. The program ends on an invalid job code. Assume other data is valid.
Processing:
Compute the employee code as the first letter of first name and last letter of last name (ex. "JS").
Use a switch statement to process the job type (H, S) with a default branch that exits the program
on invalid job type character.
Compute the gross pay. For an hourly person, the person receives the hourly rate for hours <=
40 and overtime rate (1.5 times the hourly rate) for hours over 40. For example, if the person worked 45 hours, they would get 40 hours at the hourly rate and 5 hours at the overtime rate. For a salaried employee, the gross pay is the base salary.
Federal tax is 0.22 * (gross pay - dependents * 24.32).
State tax is 4% of gross pay.
Net pay is gross pay minus federal tax minus state tax.
Output:
Report the job code and payroll values. Use the NumberFormat class for currency format on all monetary amounts (see sample output).
Sample Output: