hi guys i'm trying to get the sum, average, and the number of values in the array greater than the average... i am new to this and keep getting errors! helllpp..
import java.util.Scanner;
public class AverageArray {
public static void main(String[] args) {
final int TOTAL_NUMBERS = 10;
int[] numbers = new int[TOTAL_NUMBERS];
float sum;
//Create a Scanner
Scanner input = new Scanner(System.in);
//Read all numbers
for (int i = 0; i < numbers.length; i++) {
System.out.print("Enter a number:");
//Conver String into integer
numbers[i] = input.nextInt();
}
//Find the sum and average
for (int i = 0; i < numbers.length; i++)
sum += numbers[i];
int average = sum / TOTAL_NUMBERS;
}
//Find the number of values in the array greater than the average
int average = 0;
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] > average) count++;
}
//Prepare the result
String output = "The array is";
for (int i = 0; i < numbers.length; i ++) {
output += numbers[i] + " ";
}
output += "n\The average is" + average;
output += "n\The number of values in the array greater than the average" + "is" + count;
//Display the result
System.out.println(output);
}
}
AverageArray.java:31: illegal start of type
for (int i = 0; i < numbers.length; i++) {
^
AverageArray.java:31: ')' expected
for (int i = 0; i < numbers.length; i++) {