Java Programming
Java Programming
9th Edition
ISBN: 9780357616635
Author: Joyce Farrell
Publisher: CENGAGE L
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
Please solve this using java Write an application that allows a user to enter the names and birth dates of up to 10 friends. Continue to prompt the user for names and birth-dates until the user enters the sentinel value “ZZZ” for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birth-date or an error message if the name has not been previously entered. The loop continues until the user enters “ZZZ” for a name.
Write an application that counts by five from 5 through 500 inclusive and that starts a new line after every multiple of 50 (50,100,150 and so on).Save the file as CountByAnything.java
A Java Practical Assignments.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View E-Sign Window Help Home Tools Java Practical Assig. x Sign In 1 /1 139% Java Practical Assignments 1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value. Prompt the user for an input value and try the Math.sqrt() method on it. The application either displays the square root or catches the thrown Exception and displays an appropriate message. 2. Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. 3. Write an application for Limpopo's Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the…
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT