DEV/DEV2.1/TP4/Moyenne.java

49 lines
498 B
Java
Raw Normal View History

2023-03-27 11:21:24 +02:00
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) {
}
}