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.
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