Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
public class AverageCalculation {
2
public static float getAverage(int[] numbers) {
3
float sum = 0.0f;
4
for (int i = 0; i < numbers.length; i++) {
5
sum += numbers[i];
6
}
7
return sum / numbers.length;
8
}
9
10
public static void main(String[] args) {
11
int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
12
System.out.println(getAverage(numbers));
13
}
14
}
15
16