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
What is an identified component of a software program that might allow a hacker or other intruder to gain entry and control of a
adell [148]

D. Vulnerability

A patch is basically the same thing as a quick bug fix.

An endpoint is basically a way to access a server/resource.

Imaging software is just a type of software.

3 0
3 years ago
Read 2 more answers
Kenny FRIEND ME. Ps that is my brother
Maslowich

Answer:

who is kenny

Explanation:

3 0
2 years ago
Read 2 more answers
What in the world is this for and how do you use it
iVinArrow [24]

Answer:

This page is so that we can ask something and help each other with those questions or school or university assignments

Explanation:

6 0
3 years ago
Read 2 more answers
True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript. Tru
Dahasolnce [82]

Answer:

True

Explanation:

3 0
2 years ago
The flagging of an uncommon last name as a spelling error can be stopped by opening the shortcut menu on the first occurrence of
Mice21 [21]

Solution:

The flagging of an uncommon last name as a spelling error can be stopped by opening the shortcut menu on the first occurrence of the name and selecting of ignoring all.

Thus the required right answer is B.

8 0
3 years ago
Other questions:
  • Throwing an improperly drained oil filter into the trash dumpster is a violation that can carry heavy penalties. A) true b) fals
    7·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    11·1 answer
  • A company has its branches spread over five places in a state. It has become difficult for employees to transfer information and
    7·1 answer
  • Do you have to make a account of Windows 10?
    12·1 answer
  • Cnt115-02* which of the following is a private ip address and can't be routed across the internet?
    12·1 answer
  • The arrows in this question indicated the determination of two attributes. For example, the arrow that goes ProductID to Product
    11·1 answer
  • Select the correct answer from each drop-down menu.
    7·1 answer
  • Write a static method called split that takes an ArrayList of integer values as a parameter and that replaces each value in the
    12·1 answer
  • Select the correct answer
    15·1 answer
  • In cell b12 create a formula using max f7nction to calculate maximum value in B4:B9
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!