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
GMI = $4,666.67 Total Monthly Deductions $1,131.00 What is the Net Monthly Income (GMI - Total Monthly Deductions) =
Kisachek [45]

Answer:

Net Monthly Income = $3,535.67

Explanation:

Given:

GMI = $4,666.67

Total Monthly Deductions = $1,131

Find:

Net Monthly Income

Computation:

Net Monthly Income = GMI - Total Monthly Deductions

Net Monthly Income = $4,666.67 - $1,131

Net Monthly Income = $3,535.67

6 0
3 years ago
What is computer hardware / software​
Pavel [41]

Answer: <u>Computer hardware is any physical device used in or with your machine, like for example, a mouse, or a keyboard.</u> Computer software is a collection of programming code installed on your computer's hard drive it can process billions of data and inputs through this.

Hope this helps!

5 0
3 years ago
Which 4 elements are commonly contained in a master page?
Arturiano [62]

Answer:

if this is in aspnet then

Step 1: Open new project in visual studio.

Step 2: Add new file in to our project.

Step 3: Design the master page, using HTML.

Step 4: Add web form in to our project.

Explanation:

7 0
3 years ago
What is the most credible website or webpage you have ever visited? Why is it so credible? Describe some of the qualities that m
8_murik_8 [283]
— Look for Sites from Established Institutions.
— Look for Sites with Expertise
— Do not click on Commercial Sites
— Beware of Bias
— Check when it was last updated, so you get recent info.
— Check Links
— Avoid Anonymous Authors.
6 0
4 years ago
Read 2 more answers
Assume the number variable contains the number 1000.
Inga [223]

Answer:

Explanation:

We could get the four options for this particular example, but we must know what happens with the variable number the value 1000.

In this case, we are going to assume four scenarios:

1) n = n - n this is equal to 0

2) n = (n - n) + n = 1000

3) n = n * 2 = 2000

4) n = n * 3 = 3000

These are simple examples, we could get these options in different ways.

5 0
3 years ago
Other questions:
  • Code Example 4-3 main program: import arithmetic as a def main(): num1 = 5 num2 = 6 result = a.add(num1, num2) print("The sum is
    15·1 answer
  • What does nntp stand for?
    12·2 answers
  • When you tap or click the ____ button for a selected graphic, Word provides options for changing how a graphic is positioned wit
    5·1 answer
  • . If you have written the following source code:
    9·1 answer
  • To use the Report Wizard to create a report for a query, select the query in the Navigation Pane, click ____ on the ribbon, and
    13·1 answer
  • Is a MODEM required for Internet Connectivity ?<br> Yes<br> No
    9·2 answers
  • The Internet was first used by which of the following institutions?
    7·1 answer
  • Does the following code return a string or a number def of() return 3
    12·1 answer
  • Which of the following is not an operating system a) boss b) window xp c) linux d) bindux​
    15·1 answer
  • Who is maintain data and time of computer?​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!