Question
Write a program that reads four numbers from the standard input and sorts them in ascending order . You can base your program on the
Write a program that reads four numbers from the standard input and sorts them in ascending order. You can base your program on the program Sort3Numbers.java for sorting three numbers that is given in class. (If you indeed base your program on Sort3Numbers.java, you can use the exact code therein and need just three more comparisons in order to sort four numbers.) Or you can come up with your own method for solving the problem. In order to receive full credit, your program must use no more than six comparisons. You will receive extra credit if your program uses only five comparisons, and for that you do need to come with different ideas. (It also turns out that five comparisons is the best possible for sorting four numbers.)
must be written in java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started