ITEC 120 Back to Assignment index page Assignment 1 - Hi Lo game Submit your program to the RU03 folder in your folder on neelix.

Description:  Write a program which asks the user how many numbers they'd like to choose from. Then, the program generates a random number between one and that number. The user then tries to guess what the random number is. After each guess, the program tells the user whether they need to guess higher or lower to get closer to the random number. The user continues guessing until they guess correctly. The program will tell the user how many guess it took them.

Feel free to use your own words when composing the messages the program generates.

Sample run:

 Program Outputs How many different numbers would you like to choose from? User Inputs 25 Program Outputs I'm thinking of a number between 1 and 25. Guess what it is: User Inputs 12 Program Outputs No, guess higher: User Inputs 20 Program Outputs No, guess lower: User Inputs 15 Program Outputs No, guess higher: User Inputs 17 Program Outputs YES! You guessed the number in 4 tries.

Another sample run:

 Program Outputs How many different numbers would you like to choose from? User Inputs 3 Program Outputs I'm thinking of a number between 1 and 3. Guess what it is: User Inputs 2 Program Outputs ***** Yahoo! You guessed right on the first try! *****

Your program will make use of loops and if statements. Remeber to document your program! Be reminded that this programming assignment is to be your own work. You may use your textbook and class notes, tutors, and your Peer Instructor for guidance.

Hints and notes:

• This problem has some in common with Lab 7. Use Lab to help you.
• Be sure to print a special message if they guess in one try (different from the message they get for multiple tries).
• Once you get a running program, you might want to print out the randomly generated number so you can test and make sure the rest of your program is working correctly. Of course you'd want to remove that line of code before turning it in.