Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im trying to write a program in javs that randomly generates a number. Then, the user is to guessing the number. Please explain in Detail.

Im trying to write a program in javs that randomly generates a number. Then, the user is to guessing the number. Please explain in Detail.

The command line Java program to input, keep track of, and check user's attempts to guess a randomly generated number. The input portion of the program will be a continuous loop, only breaking out of it when the user either guesses the correct number, or by entering -1 to signify giving up. After each guess, the user will be informed of his guess being too high, too low, or exactly correct. Upon exiting the loop, the user is given feedback of their guesses (amount guessed too low, amount guessed too high, total amount of guesses).

I want to use :

import java.util.Random; Random rand = new Random(); int value = rand.nextInt(32)+1

This is how the output is supposed to look like:

Guess the number I'm thinking of, from 1-100: 21 Your guess is larger than the random value. Next guess: 5 Your guess is larger than the random value. Next guess: 7 Your guess is smaller than the random value. Next guess: 4 You've guessed correct! Total number of guesses: 4 Smaller Guesses: 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions