01: //File:        NumberList.java
02: //This class will gather together in one place
03: //functions (or methods) which process lists of
04: //numbers (int or double).
05: import iostuff.*;
06: public class NumberList
07: {
08:         //The following two methods calculate the average of a list
09:         //of int's or double's respectively
10:         public static int average (int [] a)
11:         {
12:                 int sum=0;
13:                 for (int k=0; k<a.length; k++)
14:                 {
15:                         sum = sum + a [k];
16:                 }
17:                 return sum/a.length;
18:         }
19:         
20:         public static double average (double [] a)
21:         {
22:                 double sum=0;
23:                 for (int k=0; k<a.length; k++)
24:                 {
25:                         sum = sum + a [k];
26:                 }
27:                 return sum/a.length;
28:         }
29: }