/* 11/6/2019 Problem: given information about 5 Employees, calculate and print pay */ import java.util.Scanner; /** This is version 5a of Payroll. * Use arrays, and we know in advance how many elements * will be stored in each array. */ public class PayrollV5a { /** read in: name, ID#, rate, hours * multiply rate*hours to get gross pay */ public static void main(String[] args) { final int NUMEMPLOYEES = 5; // if I store the data in arrays, it will remain // in memory, available for the duration the pgm double[] rates = new double[NUMEMPLOYEES]; double[] hours = new double[NUMEMPLOYEES]; double[] grossPay = new double[NUMEMPLOYEES]; double[] netPay = new double[NUMEMPLOYEES]; String[] names = new String[NUMEMPLOYEES]; int[] idnums = new int[NUMEMPLOYEES]; double totalPay=0; Scanner sc = new Scanner(System.in); // gives us a Scanner object to help read int i=0; // i will be used as a counter AND as the array index while (i40 give 1.5*rate for all overtime hours if (hours[i] > 40) { grossPay[i] = (hours[i]-40)*rates[i]*1.5+40*rates[i]; } else { grossPay[i] = rates[i] * hours[i]; } // rule for taxes, 25% off if salary is > 1000 // 15% off otherwise double[] taxes = new double[grossPay.length]; if (grossPay[i] >= 1000) { taxes[i] = .25*grossPay[i]; } else { taxes[i] = .15*grossPay[i]; } netPay[i] = grossPay[i] - taxes[i]; totalPay+=netPay[i]; System.out.println(idnums[i] + " " + names[i] + " grossPay: " + grossPay[i] + " netPay: " + netPay[i]); i++; // increment counter and array index } // end while loop // fall out of while loop, print count and sum System.out.println("We processed " + NUMEMPLOYEES + " employees." + " Total pay is " + totalPay); // show that data is still available System.out.println("outside of while loop, netPay array: "); for (double pay : netPay) System.out.println(pay); sc.close(); } }