Csci122 Programming Assignment 04
Csci122 Programming Assignment 04
5
Random Number Guessing Game (30pts)
Create an application (name it "GuessingGame") that generates a random number in the range of 1 through 100 (including both 1 and 100), and asks the user to guess what the number is using an input box. If the user's guess is higher than the random number, the program should display, "Too high, try again." If the user's guess is lower than the random number, the program should display, "Too low, try again." Keep track of each guess in a ListBox that shows both the user's guess and whether it was too high or too low. The program should use a loop that repeats until the user correctly guesses the random number and when the correct number is guessed, the program should display, "Congratulations! You guessed correctly!"
2. Make sure the following properties are set for the main form: (1pt) Title should be, "Guessing Game" i. The "Guess" button is set as the form's accept button ii. The "Clear" button is set as the form's cancel button. iii. Make sure to assign the following keyboard access keys to the correct buttons: (1pt) 3. "Guess" --> Alt+g i. "Clear" --> Alt+r ii. "Exit" --> Alt+x iii.
Functionality (10pts)
1. Generate a new random number each time the game's "Guess" button is pressed. (1pt) 2. Use a loop that repeatedly asks the user to guess a number using an input box until the user correctly guesses the random number. (4pts) i. Let the user know if their previous guess was too low or too high. ii. Let the user know when they have guessed the correct number. 3. Keep track of the user's guesses by adding them to a ListBox with the latest/most current guess on top. (4pts) i. Each ListBox item should display the guess as well as whether it was too high or too low. 4. Make sure the "Exit" button closes the form and the "Clear" button clears the ListBox. (1pt)