Menu

[Solved]Write Java Program Ask User Input Sequence Numbers Compute Statistics E Min Max Average Me Q37288742

Write a Java program to ask user input a sequence of numbers,and then compute the statistics (i.e.,min, max, average, median,etc.) of the numbers. Sort the numbers in both ascending anddescending order.

Detailed Instructions

Requirements for using methods to perform these sub-tasks:

  • min:
    The method takes one double-type array as the formal parameter andreturns one double value, i.e., the minimum value. You should uselinear search, i.e., the complexity must be linear, i.e., O(n),where n is the total number of elements in the array. Sorting thearray is unnecessary and not allowed.

  • max:
    The method takes one double-type array as the parameter and returnsone double value, i.e., the maximum value. You should use linearsearch, same as in the min method.

  • sum:
    The method takes one double-type array as the parameter and returnsone double value, i.e., the total sum. Again, the complexity mustbe linear, i.e., O(n).

  • mean:
    The method takes one double-type array as the parameter and returnsone double value, i.e., the mean (or average) of all values in thearray. It should utilize the method sum.

  • stddev:
    The method takes one double-type array as the parameter and returnsone double value, i.e., the standard deviation. It should utilizethe method mean. Let m be the mean of n numbers x1, x2, , xn. Thestandard deviation σ is calculated as:

    σ =squareroot of (x1 −m)^2 +(x2 −m)^2 +…+(xn −m)^2 / n

  • sort
    The method takes one double-type array and one boolean variableflag as its parameters, and the method does not return a value. Ifthe boolean variable flag is true, sort the array in ascendingorder, otherwise sort the array in descending order.

  • median
    The method takes one double-type array as the parameter and returnsone double value, i.e., the median. If the length of the array iseven, the median is the average of the middle two elements in asorted array.

  • print:
    The method takes one double-type array as the parameter and displayeach element in the array separated by spaces. Keep 4 decimaldigits.

  • main: Test everything

  • Sample Output

  • How many numbers? 8Please enter 8 numbers (separated by space): 123 123 123 -35 0.007 -987.123 -0.0002 711Original array: 123.0000 123.0000 123.0000 -35.0000 0.0070 -987.1230 -0.0002 711.0000Min: -987.1230Max: 711.0000Mean: 7.2355Standard Deviation: 436.7674Median: 61.5035Ascending order: -987.1230 -35.0000 -0.0002 0.0070 123.0000 123.0000 123.0000 711.0000Descending order: 711.0000 123.0000 123.0000 123.0000 0.0070 -0.0002 -35.0000 -987.1230

Expert Answer


Answer to Write a Java program to ask user input a sequence of numbers, and then compute the statistics (i.e.,min, max, average, m… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *