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 MS Paint ?<br><img src="https://tex.z-dn.net/?f=%20computer" id="TexFormula1" title=" computer" alt=" computer" align="a
nignag [31]

Answer:

Microsoft Paint, also known as Paint, is a simple program that allows users to create basic graphic art on a computer. Included with every version of Microsoft Windows since its inception. Paint provides basic functionality for drawing and painting in color or black and white, and shaped stencils and cured line tools.

4 0
3 years ago
REEEEEEE I STILL NEED MORE AESTHETIC USERNAMES TO GO OFF OF PWEASE HELP IMA HAVE A PANIC ATTACK!!!... next post ima do a vote :&
aev [14]

StrawberryTeaa (could be any fruit: blueberry, peach, etc)

potatoxchip

pastelsquid

SquishyPeach

GummiBear

ElegantFlaws (could add an e and remove the s: EleganteFlaw)

hunnie_b (or honee, honnie, hunni, etc)

agonyisheree

It's cool if you don't like these. I had trouble when I changed my user too. But you'll find your perfect username eventually. :)

7 0
3 years ago
A ___________ variable is declared outside all functions.
velikii [3]

Answer:

B. global

Explanation:

A global variable lives on even when a function returns.

7 0
3 years ago
I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
elixir [45]

Answer:

The word you are looking for is "right"

Explanation:

3 0
3 years ago
Read 2 more answers
Given a line of text as input, output the number of characters excluding spaces, periods, or commas.
Flauer [41]

Answer:

<em>import java.util.Scanner;</em>

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner in = new Scanner(System.in);</em>

<em>        System.out.println("Please enter a string of words");</em>

<em>        String n = in.nextLine();</em>

<em>        int count = 0;</em>

<em>        for (int i=0; i<n.length(); i++){</em>

<em>            if((n.charAt(i) != '.') &&(n.charAt(i) != ',') && (n.charAt(i) != ' ')){</em>

<em>                count++;</em>

<em>            }</em>

<em>        }</em>

<em>        System.out.println(count);</em>

<em>    }</em>

<em>}</em>

Explanation:

  1. Prompt User to input the string and assign to a variable
  2. SET count =0.
  3. Using a for loop iterate over the string
  4.  if((n.charAt(i) != '.') &&(n.charAt(i) != ',') && (n.charAt(i) != ' ')) then count =count +1.
  5.     PRINT count.

7 0
3 years ago
Read 2 more answers
Other questions:
  • An attribute whose value uniquely identifies an object is called a(n) _______.​
    15·1 answer
  • Examine the evolution of the World Wide Web (WWW) in terms of the need for a general-purpose markup language. Provide your persp
    5·1 answer
  • IF ACCURATE = BRAINLY (if u answer rubbish randomness= reported AND if you got questions dont ask in answer slot= reported)
    13·1 answer
  • The software used to help run the computer hardware is the _____.
    9·2 answers
  • A _______ area network is a type of wireless network that works within your immediate surroundings to connect cell phones to hea
    9·2 answers
  • Select the correct statement(s) regarding partial mesh networks.
    5·1 answer
  • Let x = ["Red", 2.55,"Green", 3,"Black","false"], then solve the following:
    7·1 answer
  • ______allow you to select elements that are in a certain state, such as when the mouse if hovering over an element
    14·1 answer
  • What is a database and provide 2 examples of how you are using a database.
    5·1 answer
  • The direction of a ratchet is reversed by _______________________.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!