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
True or false The List interface defines a collection for storing elements in a sequential order.
Veseljchak [2.6K]

Answer:

True

Explanation:

A list is a collection where the elements are stored in the ordered sequence and it allows access to each of he elements by its position in the sequence. It allows duplicate values to be stored. It also allows insertion of elements and positional access.

A list is one of the three major categories of the Java collections. The other two categories are maps ans sets.

4 0
3 years ago
What is the first step in finding a solution to a problem?
Law Incorporation [45]

Answer:

Can i have a points? Tysmm

5 0
2 years ago
Read 2 more answers
5. The coordinates of triangle ABC are A(-7, 3), B(3, -7) and C(8. 8)
kati45 [8]

Answer:

b

Explanation:

6 0
3 years ago
Read 2 more answers
"Explain the functionality of the different layers found in the network protocol stack of an operating system such as Linux"
arsen [322]

Answer:

There are 7 layers in linux.

Explanation:

As networking is difficult and complex.

Imagine if every application had to know how to communicate on every step that would be more than just complex. So, rather than reinvent something which will help it to communicate let’s just make something that will automatically controls the communication and for that protocols came in to live.

As for the linux operating system, it is not exceptional from other operating systems.

There are 7 layers on network protocol stack use to communicate with other network protocol stack.

1. Application layer

2. System call interface

3. Protocol agnostic interface

4. Network protocol

5. Device agnostic interface

6. Device drivers

7. Physical hardware

All the layers vary in their functionality.

One more important thing to remember is that the network protocol stack layers is not one way its 2 way communication. First, when a client request to a network and second, when the request is full filled.

The top most layer is a part of user space, the next five layers comes in the kernel space and the final layer is the physical layer.

<u>Application layer: </u>

When a client or user request to  a network the request initially comes to this layer.

On this layer we use tcp/ip protocol.

<u>System call interface(SCI): </u>

When application layer make a call to the kernel this layer handles that call. And take the request to the next layer.

<u>Protocol agnostic interface: </u>

This layer has two functions “talking” or “listening”. There is a thing called sockets which perform these functions and each socket has an id which is used specifically for an application.

<u>Network protocol: </u>

This layer is used for how the data is sent or received.

<u>Device agnostic interface: </u>

It is used to connect data from/to kernel user space and the network device drivers which allows the data to prepare itself for transmission over the medium from the network device.

<u>Physical hardware : </u>

This layer is responsible for the data packets transmission and received from the network medium being used whether cable or wireless.

5 0
3 years ago
Which computer are used by mobile employees such as meter readers.​
Naily [24]

Answer:

Handheld/Mobile Computers

3 0
3 years ago
Read 2 more answers
Other questions:
  • A label is any word that appears in a cell of a spreadsheet.<br> True<br> False
    5·2 answers
  • Terms that represents the achual speed used by device to transfer data​
    14·1 answer
  • For Windows 9x and Windows NT operating systems, which authentication protocol should be used that protects the authentication p
    11·1 answer
  • Explain the purpose of QoS on a TCP/IP network. Define the basic purpose of IP prece- dence, Type of Service, Diffserv, and Expl
    11·1 answer
  • write the program or pseudocode algorithm that computes the product and average of three integers and display the results​
    7·1 answer
  • What is data Communications​
    11·2 answers
  • What reforms were made by the British government in India after the war of independence? write any three
    5·1 answer
  • how does a demilitarized zone (dmz) work. A.By preventing a private network from sending malicious traffic to external networks
    10·1 answer
  • Explain the different features available in Print command?
    10·1 answer
  • What are basic types of touch screen
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!