/Users/lyon/j4p/src/bookExamples/ch08ArraysAndVectors/Statistics.java

1    /* 
2     * @author Douglas A. Lyon 
3     * @version  Nov 16, 2002.8:04:25 AM 
4     */ 
5    package bookExamples.ch08ArraysAndVectors; 
6     
7    public class Statistics { 
8        public static double average(double da[]) { 
9            double n = da.length; 
10           return sum(da) / n; 
11       } 
12    
13       public static double sum(double da[]) { 
14           double s = 0; 
15           for (int i = 0; i < da.length; i++) 
16               s = s + da[i]; 
17           return s; 
18       } 
19   } 
20