EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
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,
- 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”.
- Otherwise,
- Check whether the second integer is less than or equal to the remaining integers,
- Print the integers in ascending order.
- Print the integers in descending order.
- Define the method “main ()”,
Expert Solution & Answer
Trending nowThis is a popular solution!
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)
Chapter 5 Solutions
EBK JAVA PROGRAMMING
Ch. 5 - Prob. 1RQCh. 5 - Prob. 2RQCh. 5 - Prob. 3RQCh. 5 - Prob. 4RQCh. 5 - Prob. 5RQCh. 5 - Prob. 6RQCh. 5 - Prob. 7RQCh. 5 - Prob. 8RQCh. 5 - Prob. 9RQCh. 5 - Prob. 10RQ
Ch. 5 - Prob. 11RQCh. 5 - Prob. 12RQCh. 5 - Prob. 13RQCh. 5 - Prob. 14RQCh. 5 - Prob. 16RQCh. 5 - Prob. 17RQCh. 5 - Prob. 18RQCh. 5 - Prob. 19RQCh. 5 - Prob. 20RQCh. 5 - Prob. 1PECh. 5 - Prob. 2PECh. 5 - Prob. 3PECh. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Prob. 9PECh. 5 - Prob. 10PECh. 5 - Prob. 1GZCh. 5 - Prob. 2GZCh. 5 - Prob. 3GZCh. 5 - Prob. 4GZCh. 5 - Prob. 5GZ
Knowledge Booster
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
- What is the output of the following code segment?inte=5,f=10;if(eff0) Write(Red); else Write(Orange);Â a. Red b. Orange c. RedOrange d. nothingarrow_forwardWrite an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.arrow_forwardPlease 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.arrow_forward
- Write an application that prompts for and reads the numeratorand denominator of a fraction as integers and then prints the decimal equivalent of the fraction.arrow_forwardWrite an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.cpp.arrow_forwardWrite an application that allows you to enter nine(and only nine, no more no less) integers and displays the values, their mean, and their median. (Java)arrow_forward
- Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user.arrow_forwardWrite an application to calculate how many days it is fromtoday until the end of the current year. Save the file asDaysYear.java.arrow_forwardWrite an application that determines whether a phrase entered by the user is a palindrome. A palindrome is a phrase that reads the same backward and forward without regarding capitalization, spaces or punctuation. And it will allow the user to enter as many phrases as he likes after each iteration.arrow_forward
- Write an application that allows you to enter nine integers and displays the values, their mean, and their median. (Java)arrow_forwardWhat will the following code display?try:x = float('abc123')print('The conversion is complete.')except IOError:print('This code caused an IOError.')except ValueError:print('This code caused a ValueError.')print('The end.')arrow_forwardWhat will the following code display?try:x = float('abc123')print(x)except IOError:print('This code caused an IOError.')except ZeroDivisionError:print('This code caused a ZeroDivisionError.')except:print('An error happened.')print('The end.')arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,