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]
2 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]2 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
Can I ask a computer question based on engineering?
mr Goodwill [35]
Yes you can

Hope this helps.!

6 0
2 years ago
Nick’s computer has been restarting on its own. what action should he take to solve this issue?
serg [7]
Check for possible software updates, my reasoning for that is the computer could be trying to initiate an update but is stopped by the user if you don't want it to update go to settings and turn off auto update
5 0
3 years ago
Your organization's network has multiple layers of security devices. When you attempt to connect to a service on the Internet. H
Sindrei [870]

Answer:

The host-based firewall settings are blocking the service

Explanation:

Host-based firewall settings can be configured on each workstation. The firewall can be provided by the operating system itself, or it can be a standalone software package that provides security features and functionality for the device's network connection. If this firewall contains incorrect settings, legitimate services can be blocked, and if so, a message will usually notify the user of such a breach. In these cases, the firewall settings need to be adjusted to make the desired service work.

7 0
3 years ago
After you have created at least four slides, a scroll bar containing scroll arrows and scroll boxes will appear on the right edg
neonofarm [45]

Answer:

I THINK THE ANSWER IS ''TRUE''

Explanation:

6 0
3 years ago
If you wish to sign out of your Microsoft account, tap or click ____ on the ribbon to open the Backstage view and then tap or cl
lyudmila [28]
If you wish to sign out of your Microsoft account, tap or click file on the ribbon to open the Backstage view and then tap or click the Account tab to <span>display the Account gallery, and tap or click the Sign out link. There are different ways to do that but it is the easiest.</span>
7 0
2 years ago
Other questions:
  • Consider the attack scenario given below:
    8·1 answer
  • Write a program that prints the day number of the year, given the date in the form month-day-year. For example, if the input is
    9·1 answer
  • You resurrected an old worksheet. It appears to contain most of the information that you need, but not all of it. Which step sho
    5·1 answer
  • how to answer the questions on brainly? I've typed my answer in the box but there's no submit button or whatever, and the only t
    14·2 answers
  • What is logical memory?
    15·1 answer
  • Select below the Active Directory server role that provides the functions of Active Directory without the requirements of forest
    14·1 answer
  • Which network component is used to connect one network to another? Which component delivers the message to the destination compu
    5·1 answer
  • Identify the following​
    9·1 answer
  • A large amount of data is stored in secondary storage is it true<br>​
    8·2 answers
  • Explain why you do not need expensive equipment to take pictures or record video?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!