Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 4 (Lab2b) Make sure that you are done with Lab2a before you move on to this part. In this exercise you will: a. Use
Part 4 (Lab2b) Make sure that you are done with Lab2a before you move on to this part. In this exercise you will: a. Use two methods from the Math library, namely max and min. Here is a quick introduction to these methods: 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. Let's try them out! In main, declare and initialize variables as follows: double maxNumberlMath.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 minNumber2Math.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 and ask someone. Make sure you understand how to use these methods before proceeding. b. Write a program in main that asks the user of your program to first enter his or her name followed by 3 real numbers (that is, any number from -oo to oo). Your program should sort the three numbers in descending order, then 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.3 12.2 2..3 Hi there, Leonardo! Here are the numbers you entered in descending order: 12.2 2.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 please avoid using conditionals! Make sure to run your program several times and test it with several inputs of different orderings
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