Calculating Median and mode

Trying to calculate median and mode after a user enters 10 numbers from an array.

This is what I have for the mode, but it says the mode is 0.0 everytime :/ :

Code:

`double modeOfArray=0;`

double maxValue = -1;

int maxCount = 0;

System.out.println ("This is the mode " + modeOfArray);

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

int count = 0;

for(int j = 0; j < numbers.length; j++){

if(numbers[j] == numbers[i]){

count++;

}

}

if (count > maxCount){

maxValue = numbers[i];

maxCount = count;

}

}

}

}

This is what I have for the median, and it works when the numbers are inputted, but the numbers always don't go from smallest to largest, so they need to be sorted. Any idea how to put sorting into this code for median? please help!

Code:

`double median = 0;`

double[] nums = new double[10];

if(number_of_elements % 2 == 0)

{

median = ( numbers[number_of_elements / 2] + numbers[(number_of_elements / 2) + 1] ) / 2;

}

else

median = numbers[((number_of_elements - 1) / 2) + 1];

System.out.println ("The median is " + median);

:confused: