Question: import java.util.Scanner; public class Average { public static final int MAXSIZE = 10; public static void main(String[] args) { Scanner in = new Scanner(System.in); int
import java.util.Scanner;
public class Average {
public static final int MAXSIZE = 10;
public static void main(String[] args) {
Scanner in = new Scanner(System.in); int arr[] = new int[MAXSIZE];
System.out.println("Enter " +MAXSIZE+ " integers:"); for(int i = 0; i < MAXSIZE; i++) { arr[i] = in.nextInt(); }
double average = 0; int count = 0; for(int i = 0; i < MAXSIZE; ++i) { average += arr[i]; } average /= MAXSIZE;
for(int i = 0; i < MAXSIZE; ++i) { if(arr[i] > average) { count++; } }
System.out.printf(" The average of your numbers is: %.1f ", average); if(count != 1) { System.out.println("There are " + count + " numbers above the average. "); } else { System.out.println("There is " + count + " number above the average. "); } System.out.println(" Those numbers are: "); for(int i = 0; i < MAXSIZE; ++i) { if(arr[i] > average) { System.out.println(arr[i]);
This is my code so far. I need help with the output saying "The number is:" when there is just one number that is bigger than the average.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
