[POO] sum and media added to MathTools
This commit is contained in:
parent
1d0b4e460d
commit
d4cf6f0bbd
|
@ -1,5 +1,6 @@
|
|||
package utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class MathTools {
|
||||
|
@ -20,4 +21,15 @@ public class MathTools {
|
|||
return false;
|
||||
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