Horje
get the average of an array in java Code Example
get the average of an array in java
double[] array = {19, 12, 16, 200, 13}; //Array
double total = 0; //Initialising total variable
double average = 0; //Initialising average variable

for(int i=0; i<array.length; i++){ // Looping through to retrieve total value
  total += array[i];
}

average = total / array.length; // Dividing the total by the length of the array OR number of numbers to get the average.

System.out.println("The average is: " + average);




Java

Related
sealed class java codegrepper Code Example sealed class java codegrepper Code Example
java get parent process name Code Example java get parent process name Code Example
java stream map int to char Code Example java stream map int to char Code Example
how to call super onbackpressed in fragment Code Example how to call super onbackpressed in fragment Code Example
Java array with objects from different types Code Example Java array with objects from different types Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7