Write A Java Program Called Sort That Includes Two Function Displayarray That
Write A Java Program Called Sort That Includes Two Function Displayarray That
displays the double array and sortArray that sorts the double array. The functions
are called in main. The array is created in main and assigned the valued
obtained from command line.
Class sortArray {
bubbleSort(intArray);
System.out.println("");
voidbubbleSort(double[] intArray) {
int n = intArray.length;
int temp = 0;
if(intArray[j-1] >intArray[j]){
//swap the elements!
temp = intArray[j-1];
intArray[j-1] = intArray[j];
intArray[j] = temp;
}
}
}
}
}
Output:
Array Before Bubble Sort
5.0 90.0 35.0 45.0 150.0 3.0
Array After Bubble Sort
3.0 5.0 35.0 45.0 90.0 150.0