Menu

[Solved] Objective Homework Assignment Puts Together Multiple Things Learned Semester Eg Expres Sio Q37287825

Objective

This homework assignment puts together multiple things welearned in the semester, e.g., expres- sions, arithmetics,branches, loops, I/O, methods, arrays, etc.

Part I – Programming Assignment (60 points)

Write a Java program (Statistics.java) to ask user input asequence of numbers, and then compute the statistics (i.e.,min,max, average, median, etc.) of the numbers. Sort the numbers inboth ascending and descending 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:

    (x1 −m)2 +(x2 −m)2 +…+(xn −m)2 σ=n

  • sort (extra credits: 10 pts):
    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 (extra credits: 10 pts):
    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 Outputs

    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.7674—– extra credits —–Median: 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 Objective This homework assignment puts together multiple things we learned in the semester, e.g., expres- sions, arithm… . . .

OR


Leave a Reply

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