Question: Java code please! Lab8A: For this part of the lab, refer to the lecture slides for a review of Bubble Sort. Practice re-coding the program

Java code please! Lab8A: For this part of the lab, refer to the lecture slides for a review of Bubble Sort. Practice re-coding the program given in lecture. Write a program that prompts the user to enter 10 numbers and stores the input in a 1D array of size 10. Now, use Bubble Sort to sort the arraycontinuously pushing the largest elements to the right side of the array. Every time you swap two elements in the array, you need to increment a counter. After the inner loop has completed, you need to print out the current state of the array and the total number of swaps that have occurred. The sample outputs are shown below and the user input is in bold. Note: Sample output #1 shows the worst case scenario because it has the maximum number of swaps possible. Sample output #2 shows the average scenario because it has approximately half the number of swaps.Java code please! Lab8A: For this part of the lab, refer to

Lab8A: For this part of the lab, refer to the lecture slides for a review of Bubble Sort. Practice re-coding the program given in lecture. Write a program that prompts the user to enter 10 numbers and stores the input in a 1D array of size 10. Now, use Bubble Sort to sort the arraycontinuously pushing the largest elements to the right side of the array. Every time you swap two elements in the array, you need to increment a counter. After the inner loop has completed, you need to print out the current state of the array and the total number of swaps that have occurred. The sample outputs are shown below and the user input is in bold. Note: Sample output #1 shows the worst case scenario because it has the maximum number of swaps possible. Sample output #2 shows the average scenario because it has approximately half the number of swaps. Sample output #1 Enter slot 0: 10 Enter slot 1: 9 Enter slot 2: 8 Enter slot 3: 7 Enter slot 4: 6 Enter slot 5: 5 Enter slot 6: 4 Enter slot 7: 3 Enter slot 8: 2 Enter slot 9: 1 918171615|4|32|1|10| Num swaps: 9 8171615143121910Num swaps: 17 7165|43|2|1|89|10| Num swaps: 24 615143121718910| Num swaps: 30 5|43|2|1|67|89|10| Num swaps: 35 413|2|1|516171819|10| Num swaps: 39 312|1|451617189|10Num swaps: 42 2111314151617189|10| Num swaps: 44 112131415161718910| Num swaps: 45 112131415161718910Num swaps: 45 Sample output #2 Enter slot 0 : 5 Enter slot 1: 10 Enter slot 2: 8 Enter slot 3: 2 Enter slot 4: 1 Enter slot 5: 6 Enter slot 6: 7 Enter slot 7: 3 Enter slot 8: 9 Enter slot 9: 4 58|2|16|7139|4|10| Num swaps: 8 51216171318|49|10Num swaps: 14 21115161317148 910 Num swaps: 18 1|251316471819|10| Num swaps: 21 1|2|35|4|6171819|10| Num swaps: 23 1121314151617181910 Num swaps: 24 112131415161718 910 Num swaps: 24 11213141516171819|10| Num swaps: 24 11213141516171819|10| Num swaps: 24 11213141516171819|10| Num swaps: 24

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!