Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess again. Enter number: 30 Too high! Guess again. Enter number: 15 Too low! Guess again. Enter number: 23 Too high! Guess again. Enter number: 19 Too low! Guess again. Enter number: 21 Too high! Guess again. Enter number: 20 You got it in 7 tries. Not too bad! You've got some potential. Try again? (y/n): Error! This entry is required. Try again. Try again? (y/n): x Error! Entry must be 'y' or 'n'. Try again. Try again? (y/n): n Bye - Come back soon! Specifications If the user's guess is higher than the random number, the application should display, 'Too high!' If the user's guess is lower than the random number, the application should display, 'Too low!' If the user's guess is more than 10 higher or 10 lower than the random number, the application should display, 'Way too high!' or 'Way too low!' The message that's displayed when the user gets the number should vary depending on the number of guesses. For example: Number of guesses Message ================= ======= 3 and 7 What took you so long? Maybe you should take some lessons. When the user guesses a number, the application should only accept numbers from 1 to 100. When the user responds to the Try Again? prompt, the application should only accept a value of y or n . If the user enters invalid data, the application should display an appropriate error message and prompt the user again until the user enters valid data. The code that's used to validate data should be stored in separate methods. For example: public static double getDoubleWithinRange(Scanner sc, String prompt, double min, double max) public static int getIntWithinRange(Scanner sc, String prompt, int min, int max) The code that's used to run the application should also be stored in separate methods. Use the random() method of the java.lang.Math class to generate a random number.
Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess again. Enter number: 30 Too high! Guess again. Enter number: 15 Too low! Guess again. Enter number: 23 Too high! Guess again. Enter number: 19 Too low! Guess again. Enter number: 21 Too high! Guess again. Enter number: 20 You got it in 7 tries. Not too bad! You've got some potential. Try again? (y/n): Error! This entry is required. Try again. Try again? (y/n): x Error! Entry must be 'y' or 'n'. Try again. Try again? (y/n): n Bye - Come back soon! Specifications If the user's guess is higher than the random number, the application should display, 'Too high!' If the user's guess is lower than the random number, the application should display, 'Too low!' If the user's guess is more than 10 higher or 10 lower than the random number, the application should display, 'Way too high!' or 'Way too low!' The message that's displayed when the user gets the number should vary depending on the number of guesses. For example: Number of guesses Message ================= ======= 3 and 7 What took you so long? Maybe you should take some lessons. When the user guesses a number, the application should only accept numbers from 1 to 100. When the user responds to the Try Again? prompt, the application should only accept a value of y or n . If the user enters invalid data, the application should display an appropriate error message and prompt the user again until the user enters valid data. The code that's used to validate data should be stored in separate methods. For example: public static double getDoubleWithinRange(Scanner sc, String prompt, double min, double max) public static int getIntWithinRange(Scanner sc, String prompt, int min, int max) The code that's used to run the application should also be stored in separate methods. Use the random() method of the java.lang.Math class to generate a random number.
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
Related questions
Question
Create an application that lets a user guess a number between 1 and 100.
Console
Welcome to the Guess the Number Game
++++++++++++++++++++++++++++++++++++
I'm thinking of a number from 1 to 100.
Try to guess it.
Enter number: 50
You got it in 1 tries.
Great work! You are a mathematical wizard.
Try again? (y/n): y
I'm thinking of a number from 1 to 100.
Try to guess it.
Enter number: 50
Way too high! Guess again.
Enter number: 30
Too high! Guess again.
Enter number: 15
Too low! Guess again.
Enter number: 23
Too high! Guess again.
Enter number: 19
Too low! Guess again.
Enter number: 21
Too high! Guess again.
Enter number: 20
You got it in 7 tries.
Not too bad! You've got some potential.
Try again? (y/n):
Error! This entry is required. Try again.
Try again? (y/n): x
Error! Entry must be 'y' or 'n'. Try again.
Try again? (y/n): n
Bye - Come back soon!
Specifications
If the user's guess is higher than the random number, the application should display, 'Too high!'
If the user's guess is lower than the random number, the application should display, 'Too low!'
If the user's guess is more than 10 higher or 10 lower than the random number, the application should display, 'Way too high!' or 'Way too low!'
The message that's displayed when the user gets the number should vary depending on the number of guesses. For example:
Number of guesses Message
================= =======
3 and 7 What took you so long? Maybe you should take
some lessons.
When the user guesses a number, the application should only accept numbers from 1 to 100.
When the user responds to the Try Again? prompt, the application should only accept a value of y or n .
If the user enters invalid data, the application should display an appropriate error message and prompt the user again until the user enters valid data.
The code that's used to validate data should be stored in separate methods. For example:
public static double getDoubleWithinRange(Scanner sc, String prompt,
double min, double max)
public static int getIntWithinRange(Scanner sc, String prompt,
int min, int max)
The code that's used to run the application should also be stored in separate methods.
Use the random() method of the java.lang.Math class to generate a random number.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images
Knowledge Booster
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
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education