454,638 Members | 1,408 Online
Need help? Post your question and get tips & solutions from a community of 454,638 IT Pros & Developers. It's quick & easy.

# How to average gross/net pay of employees

 P: 2 i'm writing a java payroll program for class. I am at the end of the program but I can not figure out how to average the gross/net pay of all employees entered. I know that I must create an array but can not figure out how to get the averages......here is a copy of my code. Expand|Select|Wrap|Line Numbers import java.util.Scanner;   public class Payroll  {       private static Object employeeName;       public static void main(String[] args)     {         Scanner input = new Scanner ( System.in );         double hourlyRate=0;  // Calculated hourly pay rate for the employee         double hoursWorked =0; // Calculated hours worked for the week         double grossPay = 0; // Calculated weekly pay before taxes         double netPay; // Calculated weekly pay after taxes         double overTime = 0; // Calculated hours over 40 at rate of hourly plus half         double taxRate = .10; // Calculated tax rate for all employees         double healthCare = .05;  // Calculated rate for employees with healthcare insurance         int employeesProcessed = 0; // Number of employees entered by user         double healthCareOption; // Input from User         double healthCareCost; // the cost of health care for the employee         int totalNumberEmployees; // the total number of employees entered by user         double[] averageGrossPay= new double [employeesProcessed]; // average gross pay for all users entered in the program         double[] averageNetPay= new double[employeesProcessed]; // average net pay of all users entered in the program         double[] totalGrossPay= new double[employeesProcessed]; // total gross pay of all employees entered         double[] totalNetPay= new double [employeesProcessed]; // total net pay of all employees entered         double sum;           System.out.println ("How many employees will be processed: "); // User inputs # of employees that will be entered         employeesProcessed = input.nextInt();           for (int count = 1; count <= employeesProcessed; count ++) // loop will continue until the number of employees that the user entered is complete         { [**snipped**]                     grossPay = (hourlyRate * hoursWorked + overTime);         System.out.printf("%s's total gross pay this week is: \$%.2f\n", employeeName, grossPay); // program calculates gross pay         System.out.println();   [**snipped**]       } // end loop           for (int i=0; i