[POO] sum and media added to MathTools

This commit is contained in:
TiagoRG 2023-05-08 17:35:21 +01:00
parent ec833ad896
commit e40301c1e3
1 changed files with 12 additions and 0 deletions

View File

@ -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();
}
}