Question: Part 3 - Math Library, Scanner Lab 2 B Make sure that you are done with Lab 2 A before you move on to this

Part 3- Math Library, Scanner
Lab2B
Make sure that you are done with Lab2A before you move on to this part. In this exercise you will:
Use two methods from the Math library, max and min. They each take two numeric inputs (i.e. arguments) and return whichever number is the maximum or minimum (depending on if you are using max or min) of the two. In main, declare and initialize variables as follows:
double maxNumber1= Math.max(22.3,34.5); double minNumber1= Math.min(3.6/7.2,3.8/6.9); double maxNumber2= Math.max(2/3,0.1); double minNumber2= Math.min(13.5555,13.5556);
What are their values? Write them down somewhere. Now print them to the screen. Did you get what you expected? If not, reflect on the reason. Record the comparison of the results as comments in your code.
Make sure you understand how to use these methods before proceeding.
Write a program in main that asks the user of your program to enter their name followed by 3 real numbers (that is, any number from to ). Next, make your program sort the three numbers in descending order. Finally, print to the screen a greeting to the person and the sorted numbers.
For example (your input in blue),
Please enter you name followed by three numbers (space separated): Leonardo -22.312.22.3 Hi there, Leonardo! Here are the numbers you entered in descending order: 12.22.3 and -22.3 Thank you for using the three-number-sorting system! Good-bye.
Note: You must use the Math.max and Math.min methods introduced above. The class has not covered conditionals, so do not use conditionals for this problem!
Make sure to run your program several times and test it with several inputs of different order.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!