Hi guys i'm new to programming and i'm supposed to do a sum then average in which the output requests for four numbers from user then takes those #'s add them up and get the average then do a number of values in the array greater than the average is... I keep getting stuck on the formula portions and im pretty sure there will be more errors after that but right now i'm trying to get past these to errors. please help! Thanks!
import java.util.Scanner;
public class AverageArray {
public static void main(String[] args) {
final int TOTAL_NUMBERS = 4;
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++)
float sum += numbers[i];
int average = float sum / TOTAL_NUMBERS;
}
//Find the average of the largest number
int count = 0
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] == max) 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);
}
}
errors
AverageArray.java:23: '.class' expected
float sum += numbers[i];
^
AverageArray.java:23: not a statement
float sum += numbers[i];
^