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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

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.
Transcribed Image Text: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.
Expert Solution
Step 1

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

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education