* Write a program named GuessingGame that generates a random number between 50 and 90. Ask a user to guess the random number, then display the random number and a message indicating whether the user's guess was too high, too low, or correct. Hint: To generate a Random number use Random ranNumberGenerator = new Random(); int randomNumber; randomNumber = ranNumberGenerator.Next(min, max); */

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

Pls help ASAP. 

Write a program named GuessingGame that generates a random number between
50 and 90. Ask a user to guess the random number, then display the random number
and a message indicating
whether the user's guess was too high, too low, or correct.
Hint: To generate a Random number use
Random ranNumberGenerator = new Random();
int randomNumber;
randomNumber = ranNumberGenerator.Next(min, max);
*
*/
Transcribed Image Text:Write a program named GuessingGame that generates a random number between 50 and 90. Ask a user to guess the random number, then display the random number and a message indicating whether the user's guess was too high, too low, or correct. Hint: To generate a Random number use Random ranNumberGenerator = new Random(); int randomNumber; randomNumber = ranNumberGenerator.Next(min, max); * */
Expert Solution
Algorithm

Step 1: Declare class GuessingGame with the Main() method.

Step 2: Create an instance of Random class.

Step 3: Invoke the Next() method to generate a random number between min and max values passed as arguments.

Step 4:  Initialize count to 0 and flag to false.

Step 5: Iterate a loop until count is less than 5. Prompt and accept the guess from the user.

Step 6: Check whether the value entered by the user matches the random number. If it is true, set flag to true. Display the congrats message. 

Step 7: Otherwise, increment count. If guess is less than random number, then display that the guess is too low. Otherwise, display that the guess is too high.

Step 8: Check whether flag is false. If it is true, display the random number.

steps

Step by step

Solved in 4 steps with 2 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.
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