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

Write a Payroll class that uses the following arrays as fields: employeeID: arra

ID: 3527499 • Letter: W

Question

Write a Payroll class that uses the following arrays as fields: employeeID: array fo seven integers to hold employee id numbers. initialized with: 5658845, 4520125, 7895122, 8777541, 8451277, 13028590, 7580489 hours: an arry of seven integers to hold the number of hours worked by each employee. payRate: an arry of seven doubles to hold each employee's hourly pat rate. wages: an array of seven doubles to hold each employee's griss wages. The class should relate the data in each array through the subscripts(i.e. element 0 in hours should be hours worked of employee id in element 0. Same pay rate should be stored in element 0 of payRate array. Display each employee number and asks user to enter the employee's hours and pay rate. Should display each employee's id number and gross wage. Input Validation: Do not accept negative valuesfor hours or numbers less than 6.00 for pay rate.

Explanation / Answer

import java.util.Scanner;

public class Payroll {

    static int[] employeeID = { 5658845, 4520125, 7895122, 8777541, 8451277,
            13028590, 7580489 };
    static int[] hours = new int[7];
    static double[] payRate = new double[7];
    static double[] wages = new double[7];

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the Hours and Payrate for every employee id");
        for (int i = 0; i < employeeID.length; i++) {
            System.out.println("For Employee ID: " + employeeID[i]);
            System.out.print("Enter hours");
            do {
                hours[i] = input.nextInt();
                if (hours[i] < 0) {
                    System.out.print("Reenter hours");
                }
            } while (hours[i] < 0);
            System.out.print("Enter Payrate");
            do {
                payRate[i] = input.nextDouble();
                if (payRate[i] < 6) {
                    System.out.print("Reenter Payrate");
                }
            } while (payRate[i] < 6);
            wages[i] = hours[i] * payRate[i];
        }

        System.out.println("Employee Id      Wages");
        System.out.println("-----------      -----");
        for (int i = 0; i < employeeID.length; i++) {
            System.out.print(employeeID[i] + "          " + wages[i]);
            System.out.println();
        }
    }
}

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