Write a Java Program to find maximum or minimum value. The program displays these three options: ▪ Minimum value ▪ Maximum value ▪ Exit • If the user selected option 1, o The program generates three random numbers in range 100 to 500 and displays the random numbers that were generated. O It then shows the minimum value among the three numbers. o The program then displays the three options above. • If the user selected option 2, ● o ● The program generates three random numbers in range 100 to 500 and displays the random numbers that were generated. It then shows the maximum value among the three numbers. o The program again displays the three options above. If the user selected option 3, the program displays "Exited" message and terminates. NOTE: The program should implement separate methods to find minimum and maximum value respectively.
Question 1: Loops and Method in Java using eclipse.
Add comments to the code.
Please see image attached.
![Write a Java Program to find maximum or minimum value.
The program displays these three options:
▪
Minimum value
Maximum value
▪ Exit
If the user selected option 1,
o The program generates three random numbers in range 100 to 500 and displays
the random numbers that were generated.
O
It then shows the minimum value among the three numbers.
o
The program then displays the three options above.
• If the user selected option 2,
●
●
o The program generates three random numbers in range 100 to 500 and displays
the random numbers that were generated.
It then shows the maximum value among the three numbers.
o
The program again displays the three options above.
If the user selected option 3, the program displays "Exited" message and terminates.
NOTE: The program should implement separate methods to find minimum and
maximum value respectively.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe4e72d86-d216-4977-8ee6-fe536869a207%2F355deec0-f34b-49c4-b7ab-bd5e5f028df8%2Fm64xj9f_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Algorithm of the code:
1. Create a Scanner object to input the user's choice.
2. Create a Random object to generate random numbers.
3. Store the user's choice in a variable.
4. Start a loop that runs until the user chooses to exit.
5. Within the loop, display the options for the user.
6. Prompt the user to enter their choice.
7. If the user chooses option 1, generate three random numbers and display them.
8. Find and display the minimum value of the three numbers.
9. If the user chooses option 2, generate three random numbers and display them.
10. Find and display the maximum value of the three numbers.
11. If the user chooses option 3, exit the program.
12. If the user chooses an invalid option, display an error message.
13. End the loop.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)