18 lines
301 B
Java
18 lines
301 B
Java
|
public class Moyenne {
|
||
|
private int count;
|
||
|
private double sum;
|
||
|
|
||
|
public Moyenne() {
|
||
|
count = 0;
|
||
|
sum = 0;
|
||
|
}
|
||
|
|
||
|
public void add(Number n) {
|
||
|
count++;
|
||
|
sum += n.doubleValue();
|
||
|
}
|
||
|
|
||
|
public double getAverage() {
|
||
|
return sum / (double)count;
|
||
|
}
|
||
|
}
|