Does anyone know the formula to getting the median? Here is my program:

Code:`public class practice2`

{

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

int arraysize;

double value;

double [] array;

double median;

System.out.println("Please enter the size of the array? (Only numbers greater than 0)");

arraysize = input.nextInt();

array = new double [arraysize];

for(int i = 0; i < arraysize; i++)

{

System.out.println("Enter the value of the array " + i + ".");

value = input.nextDouble();

array[i] = value;

}

median = median (array);

System.out.println("Median value is " + median);

}

public static double median(double[] array)

{

double value = 0;

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

{

value += array[i];

}

return value/array.length;

}

}

It is giving me the average and I need the median.