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

/** * Chapter 7 * Programming Challenge 2: Payroll Class * The Payroll class sto

ID: 3657648 • Letter: #

Question

 /**  * Chapter 7  * Programming Challenge 2: Payroll Class  * The Payroll class stores information   * about employee's payroll data using  * parallel arrays.  */  public class Payroll {    // Declare a constant called NUM_EMPLOYEES for the number of employees, set it equal to 7             // Declare an array of employee ID numbers called "employeeID" AND initialize it to the values given in the book    // Remember, this is an attribute, declare it private         // Declare an array called "hours" to hold the hours worked by each employee, size it using the constant above.    // Remember, this is an attribute, so declare it private        // Declare an array called "payRate" to hold the pay rate for each employee, size it using the constant above.    // Remember, this is an attribute, declare it private         /**     * setEmployeeIdAt method     * UML method description:  +setEmployeeIDAt(int i, int id):void     * Sets the ID for the specified employee by accessing the employeeID array.     */           /**     * setHoursAt method     * UML method description:  +setHoursAt(int i, int h):void     * Sets the hours for the specified employee by accessing the hours array.     */         /**     * setPayRateAt method     * UML method description:  +setPayRateAt(int i, double p):void     * Sets the pay rate for the specified employee by accessing the payRate array.     */         /**     * getEmployeeIdAt method     * UML method description:  +getEmployeeIDAt(int i):int     * Returns the ID for the specified employee by accessing the employeeID array.     */         /**     * getHoursAt method     * UML method description:  +getHoursAt(int i):int     * Returns the hours worked for the specified employee by accessing the hours array.     */      /**     * getPayRateAt method     * UML method description:  +getPayRateAt(int i):double     * Returns the pay rate for the specified employee by accessing the payRate array.     */         /**     * getGrossPay method     * UML method description:  +getGrossPay(int i):double     * Returns the gross pay for the employee by accessing the hours and payrate for that employee and computing it.     * The data for that employee is stored at element i of each array.     */          } //end class Payroll 
 
 --------------------------------------------- 
 
 import java.util.Scanner; import java.text.DecimalFormat;  /**  * Chapter 7  * Programming Challenge 2: Payroll Class  * This program demonstrates the Payroll class.  */  public class PayrollDemo {    public static void main(String[] args)    {       // Declare a constant called NUM_EMPLOYEES for the number of employees, set it equal to 7                   //declare 2 local variables called "hours" and "payRate"              // Create a Scanner object for keyboard input              // Create a Payroll object call EmpPayRoll from the class Payroll              // Use a for loop to ask the user to enter the hours and pay rate for each employee and store them to your       //    EmpPayRoll object.       for (int i = 0; i < NUM_EMPLOYEES; i++)       {          // Get the hours worked for the given employee.          System.out.print("Enter the hours worked by employee number " + EmpPayRoll.getEmployeeIdAt(i) + ": ");                    //read in the value entered and store it in the local variable "hours"                     // Use a while loop to validate the hours entered, be sure the value entered is > 0.  If it is a negative           //   number, request the data again until is it valid                     // Get the hourly pay rate for the given employee.          System.out.print("Enter the hourly pay rate for employee number " + EmpPayRoll.getEmployeeIdAt(i) + ": ");                     //read in the value entered and store it in the local variable "payRate"                     // Use a while loop to validate the pay rate entered, be sure the value entered is > 6.0.  If it is not,           //   request the data again until is it valid                     // Store the data collected from the user in your EmpPayRoll object, by calling the appropriate set methods.               }              // Create a DecimalFormat object to format output for the gross pay - "#,##0.00".               // Display the payroll data for each employee.       System.out.println(" PAYROLL DATA");       System.out.println("============");              // Use a for loop to print the ID and gross pay for each employee.  You will need to call the appropriate method       //    to calculate/return the gross pay for each employee     } } 

Explanation / Answer

Make the clasees of the programm and use double than it will be as under : - public class Payroll { private int[] employeeID = {5658845,4520125,7895122,8777541,8451277,1302850,7580489}; private int[] hours = new int[7]; private double[] payRate = new double[7]; private double[] grossWages = new double[7]; public int getEmployeeID(int i) { return employeeID[i]; } public int getHours(int i) { return hours[i]; } public void setHours(int hours, int i) { this.hours[i] = hours; } public double getPayRate(int i) { return payRate[i]; } public void setPayRate(double payRate, int i) { this.payRate[i] = payRate; } public double getGrossWages(int i) { return grossWages[i]; } public void setGrossWages(int i) { grossWages[i] = payRate[i] * hours[i]; } } import java.util.Scanner; public class PayrollDemo { public static void main(String[] args) { Scanner input = new Scanner(System.in); Payroll employee = new Payroll(); for(int i = 0; i