Random Numbers: Most computer programs do the same thing every time they run; programs like that are called deterministic. Usually, determinism is a good thing, since we expect the same calculation to yield the same result. But for some applications, we want the computer to be unpredictable. Games are an obvious example, but there are many others, like scientific simulations. We have already seen java.util.Random, which generates pseudorandom numbers. The method nextint takes an integer argument, n, and returns a random integer between 0 and n - 1. Assignment For this assignment you will write a program in java to simulate a guessing game. Your program will generate a random number in a certain range (let the user define the range) and ask the user to guess what number it is. Give the user a certain number of tries while you narrow down the possibilities. For example, let's say the number generated is 67 and the user has 5 tries, this could be your program's output: This is a guessing game. Please enter the lower and highest values for the range: 1 100 I'm thinking of number between 1 and 100. Guess what it is: 50 Too low! Try again: 75 Too high! Try again: 65 To low! Try again: 70 To high! Try again: 68 You lost! The number was 67.

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

Java code

Screenshot and output is must

Random Numbers:
Most computer programs do the same thing every time they run; programs like that are called
deterministic. Usually, determinism is a good thing, since we expect the same calculation to yield
the same result. But for some applications, we want the computer to be unpredictable. Games
are an obvious example, but there are many others, like scientific simulations.
We have already seen java.util.Random, which generates pseudorandom numbers. The
method nextint takes an integer argument, n, and returns a random integer between 0 and n - 1.
Assignment
For this assignment you will write a program in java to simulate a guessing game. Your program
will generate a random number in a certain range (let the user define the range) and ask the user
to guess what number it is. Give the user a certain number of tries while you narrow down the
possibilities. For example, let's say the number generated is 67 and the user has 5 tries, this
could be your program's output:
This is a guessing game.
Please enter the lower and highest values for the range: 1 100
I'm thinking of number between 1 and 100. Guess what it is:
50
Too low! Try again:
75
Too high! Try again:
65
To low! Try again:
70
To high! Try again:
68
You lost! The number was 67.
Transcribed Image Text:Random Numbers: Most computer programs do the same thing every time they run; programs like that are called deterministic. Usually, determinism is a good thing, since we expect the same calculation to yield the same result. But for some applications, we want the computer to be unpredictable. Games are an obvious example, but there are many others, like scientific simulations. We have already seen java.util.Random, which generates pseudorandom numbers. The method nextint takes an integer argument, n, and returns a random integer between 0 and n - 1. Assignment For this assignment you will write a program in java to simulate a guessing game. Your program will generate a random number in a certain range (let the user define the range) and ask the user to guess what number it is. Give the user a certain number of tries while you narrow down the possibilities. For example, let's say the number generated is 67 and the user has 5 tries, this could be your program's output: This is a guessing game. Please enter the lower and highest values for the range: 1 100 I'm thinking of number between 1 and 100. Guess what it is: 50 Too low! Try again: 75 Too high! Try again: 65 To low! Try again: 70 To high! Try again: 68 You lost! The number was 67.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Files and Directory
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