// 11/08/2017 /** The Payroll class calculates the Net Pay for several * employees. This is version 6c of the Payroll class which modifies * version 5c. * This version uses ARRAYS. * The latest time we modified this pgm is 11/27/2017 where we * illustrated PARTIALLY FILLED ARRAYS. * */ import java.util.Scanner; public class Payroll6c { /** * pay is calculated by multiplying hours by rate. */ public static void main(String[] args) { // declare arrays for each piece of information necessary // to store about an employee. // these are parallel arrays, each location [numEmps] represents // info about employee i. final int MAXSIZE = 250; final double TAXES = .017; double[] rate = new double[MAXSIZE]; double[] pay = new double[MAXSIZE]; int[] hoursWorked = new int[MAXSIZE]; String[] name = new String[MAXSIZE]; Scanner readObject = new Scanner(System.in); double totalPay=0; double[] taxes = new double[MAXSIZE]; int[] idnum = new int[MAXSIZE]; System.out.print("Enter idnum (-1 to exit): "); int numEmps=0; // this keeps track of index into arrays // and the number of employees read in idnum[numEmps] = readObject.nextInt(); // Structured Read Loop while (idnum[numEmps] !=-1) { readObject.nextLine(); // to skip newline in input buffer // prompt the user to enter a name System.out.print("Enter a name of employee: "); name[numEmps] = readObject.nextLine(); // prompt the user to enter data for hours and rate System.out.print("Enter number of hours worked and rate of pay: "); hoursWorked[numEmps] = readObject.nextInt(); rate[numEmps] = readObject.nextDouble(); pay[numEmps] = rate[numEmps] * hoursWorked[numEmps]; taxes[numEmps] = TAXES*pay[numEmps]; pay[numEmps]-=taxes[numEmps]; totalPay+=pay[numEmps]; // add this employee's pay to the total numEmps++; readObject.nextLine(); // to skip newline in input buffer // end of loop read for Structured Read Loop System.out.print("Enter idnum (-1 to exit): "); idnum[numEmps] = readObject.nextInt(); } System.out.println("You entered " + numEmps + " employees." + "\nTotal Pay is: " + totalPay); // use loop to print all data System.out.println("ID Name Hours Rate Pay"); System.out.println("----------------------------------"); for (int i=0; i