[POO] sum and media added to MathTools
This commit is contained in:
parent
ec833ad896
commit
e40301c1e3
|
@ -1,5 +1,6 @@
|
||||||
package utils;
|
package utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class MathTools {
|
public class MathTools {
|
||||||
|
@ -20,4 +21,15 @@ public class MathTools {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double sum(List<Double> list) {
|
||||||
|
double sum = 0;
|
||||||
|
for (double n : list)
|
||||||
|
sum += n;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double media(List<Double> list) {
|
||||||
|
return sum(list) / list.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue