Ask Question
6 October, 06:03

Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max.

Ex: If the input is:

15 20 0 5

the output is:

10 20

+5
Answers (1)
  1. 6 October, 08:53
    0
    import java. util. Arrays;

    import java. util. Scanner;

    public class TestClock {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("How many numbers are you dealing with");

    int numList = in. nextInt ();

    int []numArray = new int[numList];

    for (int i=0; i
    System. out. println ("Enter the values");

    numArray[i] = in. nextInt ();

    }

    //Finding average

    int sum = 0;

    for (int i=0; i
    sum = sum+numArray[i];

    }

    int average = sum/numList;

    //Finding the maximum

    int max = numArray[0];

    for (int i = 0; i
    if (numArray[i]>max) {

    max = numArray[i];

    }

    }

    System. out. println (Arrays. toString (numArray));

    System. out. println (max+" "+average);

    }

    }

    Explanation:

    Create an array to hold the values to be entered by the user Using a for statement sum up the elements of the array and find their average Using another for loop find the maximum value in the array Output the array Output the maximum and average
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers