Write a program that takes 10 floating- point numbers as inputs. The program displays the average of the numbers followed by all of the numbers that are greater than the average. As part of your design, write a method that takes an array of doubles as a parameter and returns the average of the data in the array.

Respuesta :

Answer:

Explanation:

import java.util.Scanner;

public class Aver {

public static void main(String[] args) {

}

public double aver(double[] number) {

   Scanner scanner = new Scanner(System.in);

   int x = 0;

   double sum = 0;

   double[] numberList = new double[10]; //array to hold all numbers

   double[] largerList = new double[10]; //array to hold numbers greater than the average

   int numberIndex = 0;

   int largerIndex = 0

   System.out.printf("Please enter 10 floating-point numberes.\nIf more than 10 values are entered, the numbers following 10 are ignored.\nIf less than 10 numbers are entered, the program will wait for you to enter 10.\nTHANKSS");

   for (int i = 0; i < 10; i++) {

       try {  

           x = scanner.nextInt();

           sum += numberList[x]; //add up all inputs to find SUM

       } catch (Exception e) {

           System.out.println("Invalid input! Please reenter 10 integer values.");

           scanner = new Scanner(System.in);

           i = -1;

           numberIndex = 0;

           largerIndex = 0;

           numberList = new double[10];

           largerList = new double[10];

           continue;

       }

   }

   for (int i = 0; i < number.length; i++) {

       sum = sum + number[i];

       double average = sum / number.length;

       System.out.println("Average value of your input is: " + average);

       System.out.println();

   

       if (x > average) {

           largerList[largerIndex] = x; //add negative input to negative List array

           largerIndex = largerIndex + 1;

       }

   }

   for (int i = 0; i < largerIndex; i++) {

       System.out.println(largerList[i]);

   }

   return 0;

}

I am writing a program that takes 10 floating point numbers as inputs, and displays the average of the numbers followed by all of the numbers that are ...