import java.util.Scanner;

public class Median {
    public static void main(String[] args) {
        String userInputStr;
        double medianNum;
        int numofNum;
        Scanner inputStream = new Scanner(System.in);

        System.out.print("how many values would you like to input?");
        userInputStr = inputStream.nextLine();
        numofNum = Integer.parseInt(userInputStr);

        double[] arr = new double [numofNum]; //creates array with doubles, numofNum number of values in the array
        for (int i=0; i<numofNum; i++)       //gets info from user for each spot in array
        {
            System.out.print("\nenter value: ");
            userInputStr = inputStream.nextLine();
            arr[i] = Double.parseDouble(userInputStr);
            System.out.print(arr[i]);
        }
        int n = arr.length;
        System.out.println("\nMedian: " + findMed(arr, n));
    }

    public static double findMed(double arr[], int n)
    {
        // sort the array
        Arrays.sort(arr);
 
        // check for even case
        if (n % 2 != 0)
        {
            return (double)arr[n / 2];
        }
        return (double)(arr[(n - 1) / 2] + arr[n / 2]) / 2.0;
    }
}

Median.main(null);
how many values would you like to input?
enter value: 2.2
enter value: 1.1
enter value: 4.4
enter value: 5.5
enter value: 3.3
enter value: 6.6
Median: 3.85