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]
3 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]3 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
4. When you're working with a word processing document and you press the Del key, what happens?
Thepotemich [5.8K]
When you're working with a word processing document and you press the Del key, C. The entire document is deleted.

I have actually tried doing this to know which choice is the correct answer. I opened a new document, typed some words then pressed the Del key.... NOTHING HAPPENED! The character to the right of the cursor was not deleted, the entire document was not deleted, nor was the formatting style deleted.

I chose letter C because after seeing that nothing happened in an open document, I saved said document and opened the folder where the document was saved. I selected the document and pressed the Del key... a prompt appeared asking me if I was sure that I want to move my file to the Recycle Bin? I clicked yes... the entire document is deleted

7 0
3 years ago
Read 2 more answers
Are the actions legal or illegal?
garik1379 [7]

Answer:

No, Company will not pay

Explanation:

At the last point of the final deal, any significant sum of money does not fall into the frame.

It was important to address the exact amount needed to update the research on agriculture. They might be asking for inflated amounts.

3 0
3 years ago
Best way to build a model bridge
DanielleElmas [232]
Personally, i would use a 3-D printer, but you can use any material that you have, and have an example next to you for reference if you aren't going to 3-D print.

7 0
3 years ago
Read 2 more answers
Universal Containers (UC) has decided to build a new, highly sensitive application on the Force platform. The security team at U
Tresset [83]

Use an AppExchange product that does fingerprint scanning with native Salesforce Identity  Confirmation

8 0
3 years ago
• What advantage does a circuit-switched network have over a packet-switched network? What advantages does TDM have over FDM in
lions [1.4K]

Answer:

Advantages of both circuit switched networks and TDM are given below:

Explanation:

Advantages of circuit switched network over packet switched network:

  • Circuit switched network has the advantage of being physically connected and having a dedicated channel for communication between the sender and the receiver which also makes it more reliable. Packet switched networks do not have a dedicated channel hence, they are not that reliable.
  • Circuit switched networks are used for voice calls because there is no timing jitter or delay in these types of networks while packet switched networks do not offer this advantage.

Advantages of TDM over FDM in a circuit switched network:

  • TDM is time division multiplexing i.e. multiple information is sent in different time intervals but on the same frequency. While FDM sends information using different frequencies. So, the advantage of using TDM is that the information will be sent from the sender to the receiver using only a single frequency.
  • Using TDM, bandwidth is saved because it only sends information on a single frequency unlike FDM.
  • In TDM, there is low chance of interference between signals since they are sent in different time intervals from the sender to the receiver. While FDM has a higher chance of interference.
4 0
3 years ago
Other questions:
  • Which wireless technology has a typical transfer rate of 1 Mbps to 3 Mbps at distances up to about 10 meters?
    7·1 answer
  • A hub or ____ is a central point that connects several devices in a network together.
    11·1 answer
  • A program that coaches you at each step in the process is said to have a(n)
    12·2 answers
  • A colleague asks you to research a CPU for a new server that will run Windows Server 2019. He explains the server roles that he
    7·1 answer
  • Choose the statement that describes an advantage of paying a bill through the mail with a check.
    6·2 answers
  • to see which employees received 3 or more bonuses. use the highlight cells rules conditional formatting to format cells in the r
    6·1 answer
  • Miley met up with a bunch of her college friends after several years. She told them that she works for the sound department of a
    5·1 answer
  • There are some games that cannot be described by a single--or even two-- genres. Can you think of any that should be invented?​
    6·1 answer
  • 2. What is MOST TRUE of a mature technology?
    7·1 answer
  • Provide 3to 4 sentence overview of microsoft windows features?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!