

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Smith; Class: Algorithmic Problem Solving; Subject: Computer Science; University: East Carolina University; Term: Unknown 1989;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Write a Java program complete with full documentation to play the game, "GUESS THE NUMBER", with a human user. Your program must randomly select a target integer from 1 to 64, and it is up to the program user to guess the correct number. After each guess, the program must tell the user if the guess is too high, too low, or correct. A sample interaction would be the following (suppose the random target number selected was 40). The user input will be underlined.
Welcome to the GUESS THE NUMBER program.
Make a guess (from 1 to 64) and press RETURN 32 Your guess of 32 is too low.
Make a guess (from 1 to 64) and press RETURN 48 Your guess of 48 is too high.
Make a guess (from 1 to 64) and press RETURN 40 40 is CORRECT!!
In order to obtain the random number to be guessed, download GuessNum.java from the CSCI 2310 web page. This contains the definition of a code segment that will provide you with a random number to guess. You will have to include this code appropriately as part of your overall program for playing the game. It will define a variable named target that will contain the number to guess.
Note that as part of the execution of this code it will prompt you with the statement “Enter integer seed from 1 to 100000”. The purpose of this is to initialize the random number generator. This will not be the actual random number generated. What you are able to rely on is that every time you execute the program and input a particular number as the integer seed, the random number generated will always be the same.
The program normally terminates when the person makes a correct guess. However, we do not wish to waste computing resources on a user who is not guessing intelligently. Define a constant MAXGUESSES and set it to 8. See page 57 of your text for information about defining constants. Whenever the number of guesses that a user makes will exceed MAXGUESSES without having given a correct guess, the program should issue an appropriate message saying that the user has exceeded the maximum number of guesses, and terminate the program.
DUE DATE: March 26 at the start of class.