Write a Console Java program to implement the following Sorting Program.
Generate 20 random integers in the range of 10 to 100 and place them in an array. Sort the array in ascending order using the logic below and output both the unsorted and sorted arrays (each on a new line) on the Console separating the numbers with spaces.
The technique for this sorting program uses nested loops to make several passes through the array. Each pass compares successive pairs of elements. If the pair is in increasing order or equal leave the value as they are. If the pair is in decreasing order (i.e 2nd value is smaller than the 1st) swap the two values. First compare the first two elements and swap if needed. Then compare 2nd and 3rd elements and swap if needed. Proceed this way until you reach the end of the array. This will place the largest element at the end.
Repeat this process again. After two passes two largest numbers will be at the end. Continue until all the elements are sorted.
Complete working code is ready!