Question: Write a Payroll class using simple Java with the following fields: employeeId: An array of integers ( 7 elements ) to hold unique employee IDs,

Write a Payroll class using simple Java with the following fields: employeeId: An array of integers (7 elements) to hold unique employee IDs, initialized with specific values. hours: An array of integers to hold the number of hours worked by each employee. payRate: An array of doubles to hold each employees hourly pay rate. wages: An array of doubles to hold each employees gross wages. The Payroll class should include the following methods: 1. Calculate Gross Wages: Calculate the gross wages for each employee by multiplying their hours worked by their hourly pay rate. Store the result in the wages array. 2. Accessor and Mutator Methods: Provide accessor (getter) and mutator (setter) methods for each field. 3. Get Gross Pay by Employee ID: A method that accepts an employee ID and returns the corresponding employee's gross pay. If the ID does not exist, return a suitable error message or value. Additionally, write a separate PayrollTest class to test the Payroll class. The PayrollTest class should: Create a Payroll object and initialize it with sample data for employee IDs, hours worked, and hourly pay rates. Use the Payroll methods to calculate each employees gross pay. Display the details for each employee, including their ID, hours worked, hourly pay rate, and gross pay. Prompt the user to enter an employee ID, retrieve the gross pay for that ID, and display the result. Input Validation: Ensure that negative values for hours or pay rates below 6.00 are not accepted. Demonstrate the program by running PayrollTest and observing the output to verify the functionality of the Payroll class.

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!