CMSC 122

"Play a Game" Option


If the user selects "1" in the initial dialog box, your program will proceed as described below.

Before anything shows up on the screen, your program should determine a random value between 1 and 100. Once the value is determined, the game begins with the following prompt box:

game1

Note that the value that is displayed (in this case 61) is the random value that was determined by your program. Why on Earth would you want to reveal the number that the user is supposed to guess? (This doesn't make for a very challenging game!) Well... because your grader needs to see what number has been selected in order to test your work. If you don't display the random value in this prompt box, you will receive 0 points for this portion of the project.

After the user enters his/her guess in the prompt shown above, the program will check if the guess is correct or not. There are two cases:

  1. If the user's guess is incorrect, then one of the two prompt boxes, below, will be displayed, depending on whether the guess was smaller or larger than the "secret" number:
    game2
    game2
    Once the player has entered a new guess the program will, again, check if it is correct or not and proceed as described herein. The process repeats until the user has guessed the number correctly. Note that the secret random number will not change -- the secret number stays the same until the user guesses it correctly.
  2. Once the user has guessed correctly, an alert box like the one below appears and the game terminates. Note that you must report the number of guesses that were required for the user to guess the secret value. (If the user guessed the value correctly on the first try, your program should output "1 guess" not "1 guesses".)
    game4

Web Accessibility