Question: Write Payroll class that uses the following private arrays as fields: employeeId - An array of five integers to hold employee identification numbers hours -

Write Payroll class that uses the following private arrays as fields:

employeeId - An array of five integers to hold employee identification numbers

hours - An array of five integers to hold the number of hours worked by each employee

payRate - An array of five doubles to hold each employees hourly par rate

The class should relate the data in each array through the index/subscripts. Use appropriate constructor, set methods to initialize the array and get methods to return array.

The Payroll class should have method searchEmployee() that accepts an employee's identification number as an argument and return the gross pay (Gross pay=hours*payRate) for that employee. Use any search method (linear or binarySearch) method from the Arrays class to search the employee and return the gross pay for that employee.

Write Test class to create object of Payroll class and ask user to enter employee identification, hours worked and payRate of each employee. It should then display each employee's identification number, hours, payRate and gross pay as per display in sample run. Calculate gross pay=hours*payRate and store it in grossPay array.

Input validation: Handle proper error If employee id does not match in searchEmployee() method

When you print information in output window display numeric value using two decimal place.

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 Programming Questions!