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
ololo11 [35]
3 years ago
10

12.2 Sort an array in ascending order Write a program that gets a list of integers from input, and outputs the integers in ascen

ding order (lowest to highest). The first integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers. Ex: If the input is:
Computers and Technology
1 answer:
notsponge [240]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java, it asks the user for the number of inputs that will be made and then the inputs. These inputs are placed into an array. Then the array is sorted and printed out to the terminal.

public static void sortArrayList() {

           ArrayList<Integer> sortedList = new ArrayList();

           Scanner input = new Scanner(System.in);

           System.out.println("Enter number of digits in Array");

           int numberOfInputs = input.nextInt();

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

                   System.out.println("Enter a number");

                   sortedList.add(input.nextInt());

           }

           int n = sortedList.size();

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

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

                   if (sortedList.get(j) > sortedList.get(j + 1))

                   {

                       // swap arr[j+1] and arr[j]

                       int temp = sortedList.get(j);

                       sortedList.set(j, sortedList.get(j + 1));

                       sortedList.set(j + 1, temp);

                   }

           for (int x : sortedList) {

               System.out.println(x);

           }

       }

You might be interested in
I Promise Brainliest !!!!! Describe how the aperture size relates to the size of the lens opening.
sergey [27]

Answer:

As aperture increases in f-stop values, the lens closes. On the other hand, when aperture decreases in f-stop values, the lens opens.

Explanation:<u><em>plz give brainlist</em></u>

8 0
3 years ago
Read 2 more answers
All of the following are forms of verbal communication except
Radda [10]
B. hand gestures
these are not verbal.
4 0
3 years ago
Read 2 more answers
The power we use at home has a frequency of 60 HZ. What is the time period of such a power?
Digiron [165]

Answer:

The period of the power for our lights at home is 0.0116 s, or 16.6 ms.

6 0
4 years ago
Why does it still say I am ambitious whenever I have the 5 brainliest and almost 700 points?
Galina-37 [17]
Check below your score it should say something out of 5 you need to get more to get 5/5
8 0
3 years ago
Read 2 more answers
We have said that an application may choose UDP for a transport protocol because UDP offers finer application control (than TCP)
jolli1 [7]

Answer:

UDP has more control as compare to TCP in terms of data and time.

a. In terms of data, an application has more control in UDP as compare to TCP, in terms of confidentiality and security of Data. As UDP use the process of encapsulation to secure the information, this will cause that UDP will know that what data is sent.

b. UDP has the ability to control the flow of data and traffic congestion control, while TCP has no congestion control which causes extra delays in application. Due to this reason UDP has better control over time to send the data.

<em>We can say that, UDP has better control than TCP.</em>

4 0
3 years ago
Other questions:
  • Given a floating point variable fraction, write a statement that displays the value of fraction on the screen. Do not display an
    13·1 answer
  • Suppose we are comparing implementations of insertion sort and merge sort on the same machine. for inputs of size n, insertion s
    10·1 answer
  • Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. End each line with a newline.
    12·1 answer
  • 1. The best program to present numerical data in would be ____. a. Access c. PowerPoint b. Excel d. Word
    6·1 answer
  • Who can help me on my school we will to google meet and i share my screen
    5·1 answer
  • Electronic business includes which of the following
    5·2 answers
  • The online underground is used _____. Select 3 options. by law-abiding citizens only on Black Friday for networking by criminal
    11·1 answer
  • Java: Programming Question: Reverse OrderWrite a program that reads ten integers into an array; define another array to save tho
    10·1 answer
  • Line 9 and 10
    15·1 answer
  • I can login to it says to me u cant login at that time
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!