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
lozanna [386]
3 years ago
7

Complete the AscendingAndDescending application so that it asks a user to enter three integers. Display them in ascending and de

scending order.An example of the program is shown below:Enter an integer... 1 And another... 2 And just one more... 3 Ascending: 1 2 3 Descending: 3 2 1GradingWrite your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade.Once you are happy with your results, click the Submit button to record your score.
Computers and Technology
1 answer:
Andreas93 [3]3 years ago
5 0

Answer:

Following are the solution to the given question:

import java.util.Scanner;//import package

public class AscendingAndDescending//defining a class AscendingAndDescending  

{

   public static void main(String[] args) //main method

   {

       int n1,n2,n3,min,max,m;

       Scanner in = new Scanner(System.in);//creating Scanner class object

       System.out.print("Enter an integer: ");//print message

       n1 = in.nextInt();//input value

       System.out.print("And another: ");//print message

       n2 = in.nextInt();//input value

       System.out.print("And just one more: ");//print message

       n3 = in.nextInt();//input value

       min = n1; //use min variable that holds value

       max = n1; //use mix variable that holds value

       if (n2 > max) max = n2;//use if to compare value and hols value in max variable

       if (n3 > max) max = n3;//use if to compare value and hols value in max variable

       if (n2 < min) min = n2;//use if to compare value and hols value in min variable

       if (n3 < min) min = n3;//use if to compare value and hols value in min variable

       m = (n1 + n2 + n3) - (min + max);//defining m variable that arrange value

       System.out.println("Ascending: " + min + " " + m + " " + max);//print Ascending order value

       System.out.println("Descending: " + max + " " + m + " " + min);//print Descending order value

   }

}

Output:

Enter an integer: 8

And another: 9

And just one more: 7

Ascending: 7 8 9

Descending: 9 8 7

Explanation:

In this program inside the main method three integer variable "n1,n2, and n3" is declared that inputs value from the user end and also defines three variable "min, max, and m" that uses the conditional statement that checks inputs value and assigns value according to the ascending and descending order and prints its values.

You might be interested in
What two characteristics describe an ftp connection?.
Brrunno [24]
The first connection established is for traffic control and the second is created for transfer of a file.

Please mark as brainlest answers
5 0
2 years ago
Imagine that you work for a company directly related to your major. Your company is preparing for expansion and your boss, Ms. S
shutvik [7]

Answer:

start with what you know

Explanation:

6 0
2 years ago
Why was the microchip essential to improving computers?
-BARSIC- [3]
Because it downsized the scale of the computer itself.

5 0
3 years ago
What is the name of the book farrah gray published in 2005??
seropon [69]
He wrote Reallionaire
8 0
3 years ago
Nowadays computer games are mostly available on external<br> hard disk.<br> Is it true or false?
sergey [27]

Answer:

false

Explanation:

because a lot of times they are downloads without the disk

7 0
3 years ago
Read 2 more answers
Other questions:
  • Consider the following scenario: "You are an assistant to the accounting manager for a small company that sells sports equipment
    5·1 answer
  • When evaluating mining results, data mining and evaluating becomes
    6·1 answer
  • How to understand amortized analysis potential?
    12·1 answer
  • Which hexadecimal number is equivalent to the decimal number 11?
    13·1 answer
  • Describe how both IPv4 and IPv6 access and utilize TCP as an upper-layer transfer protocol.
    6·1 answer
  • We need an equals method for the Dog class. It needs to give back to the caller a boolean value indicating whether another objec
    5·1 answer
  • In cell B13, create a formula without a function using absolute references that subtracts the values of cells B5 and
    13·1 answer
  • A developer wants to take existing code written by another person and add some features specific to their needs. Which of the fo
    9·1 answer
  • TCP and the User Datagram Protocol (UDP) provide _________ between processes on any two of those hosts. A. address translation B
    6·1 answer
  • Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print t
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!