Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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.
expand button
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
Check Mark
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.

Knowledge Booster
Background pattern image
Computer Science
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.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education