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 Math Library, Scanner
LabB
Make sure that you are done with LabA 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 ie 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 maxNumber Math.max; double minNumber Math.min; double maxNumber Math.max; double minNumber Math.min;
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 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 Hi there, Leonardo! Here are the numbers you entered in descending order: and Thank you for using the threenumbersorting system! Goodbye.
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
