UNB/ CS/ David Bremner/ teaching/ old/ cs1083/ java/ Scores2.java
public class Scores2{

    private static final int MAX_SCORES = 100;
    private double sum;
    private int count;
    private double[] scores;

    public Scores2(int max) {
        count = 0;
        sum = 0.0;
        scores = new double[max];
    }

    public void add(double score) {
        scores[count] = score;
        sum += score;
        count++;
    }

    public double getAverage() {
        if (count == 0)
            return 0.0;
        else
            return sum / count;
    }

    public static void main (String [] args) {
        Scores2 scores = new Scores2(20);
        for (int i=0; i<20; i++){
            scores.add(i);
            System.out.println(scores.getAverage());
        }
    }
}