java buble sort code problems : Write a computer program that prompts the user for a number, creates an array for that number of random integers, and then uses the bubble sort to order the array. The program should print out the array prior to the call to the sorting algorithm and afterwards. 

I have most of the buble sort working, it is just the implementation of the random integers and user input for the size of the array that I can't seem to figure out.


        import java.util.*;
        import java.lang.*;
        import java.io.*;
        import java.util.Random;

        class Test
        {
        public static void main (String[] args) throws java.lang.Exception
        {
           int n, c, d, swap;
           Scanner in = new Scanner(System.in);
           Random r = new Random();

           System.out.println("enter number of elements to sort");
           n = r.nextInt();

           int array[] = new int[n];

           for (c = 0; c < n; c++)
           array[c] = r.nextInt();

            for (c = 0; c < ( n - 1 ); c++) {
              for (d = 0; d < n - c - 1; d++) {
               if (array[d] > array[d+1])        {
                swap       = array[d];
                array[d]   = array[d+1];
                array[d+1] = swap;
                }
               }
              }

          System.out.println("Sorted array :");

          for (c = 0; c < n; c++)
          System.out.println(array[c]);
         }
        }