1. Engineering
  2. Computer Science
  3. import javautilscanner class payroll private int employeeid 565884545201257895122 847754184512777580489...

Question: import javautilscanner class payroll private int employeeid 565884545201257895122 847754184512777580489...

Question details

import java.util.Scanner; class Payroll { private int[] employeeID ={5658845,4520125,7895122, 8477541,8451277,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; } //stes rate public void setPayRate(int index, double payrate) { payRate[index]=payrate; } //stes 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 < employeeID.length; i++) { if (employeeID [i]== theEmployeeID) { employeeIndex = i; break; } } if (employeeIndex != -1)//gross pay for if employee was found. { int h=hours[employeeIndex]; double r = payRate[employeeIndex]; grossPay =(h * r); // calculate the gross pay } return grossPay; } } import java.util.Scanner; public class payRollDemo { public static void main(String [] args) { System.out.println(" Payroll Application "); Payroll payroll = new Payroll(); Scanner kb = new Scanner(System.in); //variable declaration int hours; double payRate; double wages; int employeeID; //loop repeats for all 7 employees for (int i=0; i <7; i++) { System.out.println("Employee : " + (i + 1)); do // get the hours { System.out.print("\t Hours: "); hours = Integer.parseInt(kb.nextLine()); } while (hours <0); payroll.setHours(i, hours); do //get the payrate { System.out.print("\t Pay Rate: "); payRate = Double.parseDouble(kb.nextLine()); } while (payRate < 6.00); payroll.setPayRate(i, payRate); employeeID = payroll.getEmployeeID(i); wages=payroll.calculateGrossPay(employeeID); payroll.setWages(i, wages); } //display each employee's identification number and gross wages. System.out.println(" "); for (int i =0; i <7; i++) { System.out.print("Employee ID: " + payroll.getEmployeeID(i)); System.out.println("\t Gross Wages: " + payroll.getWages(i)); } } } when I compile is not working. the final result is missing employee ID. THE MAIN PROBLEM I HAVE IS return employeeID[index]; PLEASE HELP. THANK YOU

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution