Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write A Payroll class that use the following arrays as fields: employeeID: An ar

ID: 3636268 • Letter: W

Question

Write A Payroll class that use the following arrays as fields:

employeeID: An array of seven intergers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 845127 1302850 7580489

hours: An array of seven integers to hold the number of hours worked by each employee

payRate: An array of seven doubles to hold each employee's hourly pay rate

wages: An array of seven doubles to hold each employee's gross wages

The class should relate the data in each array through the subsciripts. For example, the number in element 0 of the hours array should be the number of hours worked by the employee whose ID number is stored in element 0 of the employeeID array. That same employee's pay rate should be stored in element 0 of the payRate array. In addition to the appropriate accessor and mutator methods, the class should have a method that accepts an employee's ID number as an arguement and returns the gross pay for that employee.

Demonstrate the class in a complete program that displays each employee number and asks the user to enter that emplyee's hours and pay rate. It should then display each employee's ID number and gross wages.

Input Validation: Do not accept negative values for hours or numbers less than 6.00 for pay rate

Explanation / Answer

import java.util.Scanner; class Payroll { private int[] employeeID ={5658845, 4520125, 7895122, 8477541, 8451277, 1302850,7580489 }; // Number of hours worked by each employee. private int[] hours = new int[7]; // Employee's hourly pay rate private double[] payRate = new double[7]; // Employee's gross wages. private double[] wages = new double[7]; // accessor and mutator methods //returns id of index public int getEmployeeID(int index) { return employeeID[index]; } //returns hours public int getHours(int index) { return hours[index]; } //returns payrate public double getPayRate(int index) { return payRate[index]; } //returns wages public double getWages(int index) { return wages[index]; } //sets ID public void setEmployeeID(int index, int ID) { employeeID[index] = ID; } //sets Hours public void setHours(int index, int hour) { hours[index] = hour; } //sets rate public void setPayRate(int index, double payrate) { payRate[index] = payrate; } //sets wages public void setWages(int index, double wage) { wages[index] = wage; } // gross pay for each employee with identification public double calculateGrossPay(int theEmployeeID) { double grossPay = 0; int employeeIndex = -1; // index of the employee for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote