Revert "Create FindAverage.java"

This reverts commit 5070a0bb28.
This commit is contained in:
rabbit 2020-08-18 09:41:32 +08:00
parent 5070a0bb28
commit 9486101fb6

View File

@ -1,25 +0,0 @@
package Maths;
public class FindAverage {
//Driver
public static void main(String[] args) {
int[] array = {2, 4, 10};
assert findAverage(array) == 5;
}
/**
* find average value of array
*
* @param array the array contains element and the sum does not
* excess long value limit
* @return average value
*/
public static int findAverage(int[] array) {
long sum = 0;
for (int i = 0 ; i < array.length; ++i) {
sum += array[i];
}
return (int)(sum / array.length);
}
}