Reference no: EM13161737
Write a method called median that accepts an array of integers as its parameter and returns the median of the numbers in the array. The media is the number that appears in the middle of the list if you arrange the elements in order. Assume that the array is of odd size (so that one sole element constitutes the median) and that the numbers in the array are between 0 and 99 inclusive. For example, the median of [5, 2, 4, 17, 55, 4, 3, 26, 18, 2, 17] is 5 and the median of [42, 37, 1, 97, 1, 2, 7, 42, 3, 25, 89, 15, 10, 29, 27] is 25.
Write a method that uses Arrays.sort() to sort the array into ascending order and then calculate the median. Call the method from a main program that allows the user to specify the size of the array and then enter the array elements. The method returns the median to the main program and the main program prints out the median.