EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

Question
Book Icon
Chapter 5, Problem 2PE
Program Plan Intro

Ascending and descending order

Program plan:

  • Import necessary package.
  • Create a class “AscendingAndDescending”,
    • Define the method “main ()”,
      • Declare the necessary variables.
      • Create “Scanner” object.
      • Prompt the user to enter three integers.
      • Get three integers from the user using “nextInt()”.
      • Check whether the first integer is less than or equal to the remaining integers,
        • If it is true, assign the first integer to “low1”.
        • Check whether the second integer is less than or equal to the third integer,
          • If it is true, assign the second integer to medium.
          • Assign the third integer to “high1”.
        • Otherwise,
          • Assign the third integer to “medium”.
          • Assign the second integer to “high1”.
      • Otherwise,
        • Check whether the second integer is less than or equal to the remaining integers,
          • If it is true, assign the second integer to “low1”.
          • Check whether the first integer is less than or equal to third integer,
            • If it is true, assign the first integer to “medium”.
            • Assign the third integer to “high1”.
              • Otherwise,
                • Assign the third integer to “medium”.
                • Assign the first integer to “high1”.
        • Otherwise,
          • Assign the third integer to “low1”.
          • Check whether the first integer is less than or equal to second integer,
            • If it is true, assign the first integer to “medium”.
            • Assign the second integer to “high1”.
              • Otherwise,
                • Assign the second integer to “medium”.
                • Assign the first integer to “high1”.
      • Print the integers in ascending order.
      • Print the integers in descending order.

Blurred answer
Students have asked these similar questions
Create an application that random 2 integers from 0 to 100. If a%b==0 print a/b, else reroll
Write an application that prompts a user for two integers and displays every integer between them. Display There are no integers between X and Y if there are no integers between the entered values. Make sure the program works regardless of which entered value is larger.
Write an application that asks a user to enter three integers. Display them in ascending and descending order. (Java)
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,