UNB/ CS/ David Bremner/ teaching/ java/ AverageSalary.java
import ccj.*;

public class AverageSalary
{  public static void main(String[] args)
   {  Employee[] staff = new Employee[5];
      staff[0] = new Employee("Hacker, Harry", 35000.0);
      staff[1] = new Employee("Reindeer, Rudolf", 63000.0);
      staff[2] = new Employee("Cracker, Carl", 48000.0);
      staff[3] = new Employee("Lam, Larry", 78000.0);
      staff[4] = new Employee("Sandman, Susan", 51500.0);
      double avgsal = averageSalary(staff);
      System.out.println("The average salary is " + avgsal);
   }

   public static double averageSalary(Employee[] s)
   {  if (s.length == 0) return 0;
      int i;
      double salarySum = 0;
      for (i = 0; i < s.length; i++)
         salarySum = salarySum + s[i].getSalary();
      return salarySum / s.length;
   }

}