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
What is an antispamming approach where the receiving computer launches a return attack against the spammer, sending email messag
Burka [1]

Answer:

Teergrubing.

Explanation:

Teergrubing is an antis-pamming approach where the receiving computer launches a return attack against the spammer, sending email messages back to the computer that originated the suspected spam.

It is a good antis-pamming approach because it slows response to the Simple Mail Transfer Protocol (SMTP) commands, thus tying up resources.

8 0
3 years ago
Read 2 more answers
Of the 5 factors that should be evaluated when assessing information's quality (Validity, Reliability, Accuracy, Timeliness, and
Art [367]
Validity is the best asseng information to evaluate the all factors
8 0
2 years ago
Anyone help pls ? Complete the code below to add css to make the background of the web page orange.
pochemuha

Answer:

In HTML file

<body style="background-color:orange;">

Or

In CSS file

body {

background-color: orange;

}

7 0
3 years ago
Ali rolled a ball down a hill. This graph shows the kinetic and potential energy of the moving ball.
denis23 [38]
Ghhsususuhwbababahaha
8 0
2 years ago
Only numbers should go in the columns for Payload Size and Packet Size. The sizes are in bytes. Don't forget to account for the
Anna11 [10]

Answer:

Non-Payload Bytes sent are 1476(total) - 393 (payload) = 1083 bytes

1083 (non-payload) out of 1476(total) is 73.37 %

Non-Hello bytes sent are 1476(total) - 53(hello payload) = 1425 bytes

1425(non-hello) out of 1476(total) is 96.54 %

7 0
3 years ago
Other questions:
  • A rectangular range of cells with headings to describe the cells' contents is referred to as a
    9·1 answer
  • What kind of problems could you run into if you format a cell with the wrong format for the data type?
    15·2 answers
  • Write a function called lucky_sevens that takes in one #parameter, a string variable named a_string. Your function #should retur
    15·1 answer
  • ServletConfig defines a set of methods that a servlet uses tocommunicate with its servlet container.
    5·1 answer
  • Which of the following are examples of jobs in the allied health profession? select all that apply.
    8·1 answer
  • If someone wanted to talk to a financial institution representative in person they would need to _____.
    5·1 answer
  • What is the alogarithm for solving the perimeter of a triangle
    11·1 answer
  • Write a list comprehension statement to generate a list of all pairs of odd posi
    7·1 answer
  • Write a recursive method called sumTo that accepts an integer parameter n and returns a real number representing the sum of the
    12·1 answer
  • Why are salaried employees often excluded from overtime pay
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!