Question: Payroll Class (Chapter 6 Programming Challenge 5)Design a Payroll class that has fields for an employee's name, ID number, hourly pay rate, and a number

Payroll Class (Chapter 6 Programming Challenge 5)Design a Payroll class that has fields for an employee's name, ID number, hourly pay rate, and a number of hours worked. Write the appropriate accessor and mutator methods and a constructor that accepts the employee's name and ID number as arguments. The class should also have a method that returns the employee's gross pay, which is calculated as the number of hours worked multiplied by the hourly pay rate. Write a program that demonstrates the class by creating a Payroll object, then asking the user to enter the data for an employee. The program should display the amount of gross pay earned. The solution is given now Start your Lab 4...Payroll Class ExceptionsProgramming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employees payroll. Write exception classes for the following error conditions: An empty string is given for the employee's name. An invalid value is given for the employee's ID number. If you implemented this field as a string, then an empty string would he invalid. If you implemented this field as a numeric variable, then a negative number or zero would be invalid. An invalid number is given for the number of hours worked. This would be a negative number or a number greater than 84. An invalid number is given for the hourly pay rate. This would be a negative number or a number greater than 25. Modify the given Payroll class so that it throws the appropriate exception when any of these errors occur. Demonstrate the exception classes in a program.

InvalidNameException.java (10 %)

InvalidIDException.java (10%)

InvalidHoursException.java (10%)

InvalidHourlyRateException.java (10%)

Payroll.java (25%)

PayrollDemo.java (25%

Screenshot (10%)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!