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. |
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. |
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:
Extra credit : (5 points) After the user completes one game, ask them if they'd like to play again. Continue playing games until the user answers no.