1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Helga [31]
2 years ago
13

Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort

that array – continuously pushing the largest elements to the right side
Computers and Technology
1 answer:
Diano4ka-milaya [45]2 years ago
8 0

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

   for(int i=0; i < n; i++){  

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}

You might be interested in
Web services can exchange information between two different systems only if the operating systems and programming languages upon
stich3 [128]
Because if im talking to someone in english but they are from china and communicating to me in chinese then thas what itll do
4 0
3 years ago
Select all that apply. To select more than one worksheet at the same time, which of the following keys on your keyboard can you
Colt1911 [192]
<em>Shift </em>selects multiple worksheets at the same time. <em>Ctrl</em> selects all that you selected with Ctrl pressed.
4 0
3 years ago
Why is the lack of a sense of humor a serious limitation for AI?
sergejj [24]

Answer:

they arent made to Express emotion? can you be a little more specific with the question?

3 0
2 years ago
Coding with Loops Worksheet
BartSMP [9]

Answer:

if you give me brainliest i will answer your question

Explan

4 0
2 years ago
Read 2 more answers
A hard disk is divided into tracks which are further subdivided into:​
marusya05 [52]

Answer:

sectors

Explanation:

hard disk contain tracks which are further divided into sectors, for storage purposes.

8 0
3 years ago
Other questions:
  • opearating system protection refers to a mechanism for controling access by programs, processes, or users to both system and use
    7·1 answer
  • Josephine is in the process of creating ads within her Standard Display campaign. She finds that there are two main ad formats t
    15·1 answer
  • Amazon Web Services and Microsoft Azure are some of the most widely used _______.
    7·1 answer
  • Select what's true about Search Engine Companies. Check All That Apply The information contained in a search engine database is
    12·1 answer
  • Joel has left his computer unattended while answering a phone call. A TV repairer in his house tries to surf through the applica
    13·1 answer
  • 14. Which of the following information about the ESRT T-teen rating rating is FALSE?
    15·1 answer
  • What are the different types of document required for mail merge?
    5·1 answer
  • What are the five Ws?<br> (I don’t even know what this means)
    5·2 answers
  • According to Okun's law, if the unemployment rate goes from 7% to 4%, what
    15·1 answer
  • Which keyboard shortcut would you press to copy cells that are selected in a spreadsheet?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!