1 4.8 (Guess the NumberGame ) Write a program that plays %u201Cguess the number%
ID: 3538407 • Letter: 1
Question
1 4.8 (Guess the NumberGame) Write a program that plays %u201Cguess the number%u201D as follows: Your program chooses the number to be guessed by selecting an i nt at random in the range 1 %u20131 000. The program then displays the following text in a label:
I have a number between 1 and 1000--can you guess my number?
Please enter your first guess.
A TextBox should be used to input the guess. As each guess is input, the background color should change to red or blue. Red indicates that the user is getting %u201Cwarmer,%u201D blue that the user is getting %u201Ccolder.%u201D A Label should display either %u201CToo High%u201D or %u201CToo Low,%u201D to help the user zero in on the correct answer. When the user guesses the correct answer, display %u201CCorrect! %u201D in a message box, change the Form%u2019s background color to green and disable the TextBox. Recall that a TextBox (like other controls) can be disabled by setting the control%u2019s Enabled property to false. Provide a Button that allows the user to play the game again. When the Button is clicked, generate a new random number, change the background to the default color and enable the TextBox.
Explanation / Answer
guessedNumber = int.Parse(textBox1.Text);
bool win = false; Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.