Skip to content

Instantly share code, notes, and snippets.

@PocasPedro
Created October 23, 2017 17:30
Show Gist options
  • Save PocasPedro/6d165423319adf4e86d456f5df485257 to your computer and use it in GitHub Desktop.
Save PocasPedro/6d165423319adf4e86d456f5df485257 to your computer and use it in GitHub Desktop.
Java Fundamentals for Kids - Exercise 16
public class MeanArray {
public static void main(String[] args) {
//Define & Initialization
int numbers[] = new int[] {196,10,6,40,44};
int sum = 0;
for(int i = 0 ; i <= 4 ; i ++){
sum += numbers[i];
}
double mean = Mean(sum, numbers.length);
System.out.println("The mean of the numbers array is: " + mean);
}
public static double Mean(int sumofall, int total){
double mean = sumofall / total ;
return mean;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment