49 lines
498 B
Java
49 lines
498 B
Java
public class Moyenne {
|
|
float value = 0;
|
|
int nbVal = 0;
|
|
public void add(int x)
|
|
{
|
|
value+=x;
|
|
nbVal++;
|
|
}
|
|
|
|
public void add(short x)
|
|
{
|
|
value+=x;
|
|
nbVal++;
|
|
}
|
|
|
|
public void add(long x)
|
|
{
|
|
value+=x;
|
|
nbVal++;
|
|
}
|
|
|
|
public void add(double x)
|
|
{
|
|
value+=x;
|
|
nbVal++;
|
|
}
|
|
|
|
public void add(byte x)
|
|
{
|
|
value+=x;
|
|
nbVal++;
|
|
}
|
|
|
|
public void add(float x)
|
|
{
|
|
value+=x;
|
|
nbVal++;
|
|
}
|
|
|
|
public float getAverage()
|
|
{
|
|
return value/nbVal ;
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
}
|
|
} |