public class chap7p4 {
public static void main(String[] args) {
int[] heights = { 33, 45, 23, 43, 48, 32, 35, 46, 48, 39, 41, };
printArray(heights);
you cannot make
String + void
findAverage method returns void
findAverage has a void return type. Change the return type for the method to return an int value
public static int findAverage(int[] array) {
...
return total / array.length;
}
Also here argument is of type int, and Operators like(*,+,..) won't work for argument type void and int so either change argument type or return type as mentioned above.
Your method findAverage(heights) has to return a value to be applicaable for the binary operator +, which takes two operants.
Return type of findAverage method should not be void it should be integer for your code.
You should not print the value of average in same method as you are calling in main method.
Change return type of your findAverage() method,
i.e void findAverage to int findAverage
public static int findAverage(int[] array) {
int total = 0;
for (int i = 0; i <= array.length; i++) {
total = total + array[i];
}
return total / array.length;
}