04-09-2012, 10:09 AM
High/Low Number Guessing Game
1HighLow Number.docx (Size: 26.26 KB / Downloads: 55)
ABSTRACT
This is a high/low number guessing game. This program is done in C++. We can work this program by selecting appropriate number from the main menu using numeric code. Computer compared the inputted number with the random number selected by computer. If the number is greater or smaller computer displays the corresponding message. During the game play, the user is given some present maximum number of chances to guess the number, failing which the user is advise.
INTRODUCTION
GamePlay is a funny term. It encompasses how fun the game is, how immense it is and the length of playability. Here we are introducing a high/low number guessing game. This program plays a simple guessing game. The computer picks a random number from 0 to 100, and the user tries to guess the number. The maximum number of chances that are allowed to the player is 7. Messages are displayed in appropriate time, to tell whether the number is high or low. Also the player is told how many chances are left. In case of successful attempt, the player is congratulated and his/her score is displayed. The interface also allows the user to specify his/her input
ANALYSIS
The computer picks a random integer from 0 to
100 (inclusive). We shall use the random method to generate a random
number. The computer asks the user for a guess. The user types a
number. The computer checks that the number is from 0 to 100. If the
number is less than 0, or greater than 100, the computer will print an
error message and ask again. This means that we should ask for a
number inside a loop. If the user’s number is less than the computer’s
number, then the computer prints a message saying that the number is
“low” and asks for a higher number. If the user’s number is greater
than the computer’s number, then the computer prints a message
saying that the number is “high” and asks for a lower number. If the
user’s number is equal to the computer’s number. Then the computer
prints a message congratulating the user, and the game will end. During
the GamePlay, the user is given some present maximum number of
chances to guess the number, failing which the user is advised to replay
the game.
PROGAMMING METHODOLOGY
This program is written in C++ language in a
simple manner. The logic of this program generates a random number
using randomize() and random() functions and lets the user enter
his/her guessed number. Then the user’s guess is compared with the
generated number, if the guessed number is not equal to the generated
number, then the computer displayed the appropriate message. If the
guessed number is equal to the generated number, user is
congratulated for it. All this is done inside a do-while loop (inner loop)
that terminates if the user has guessed a correct number or total
number of chances taken become equal to number of allowed
chances. Further an outer do-while loop gives the user a chance to
replay the game
CONCLUSION
During our academic year this program is very
useful. This is a user friendly program. Since the interface is very simple.
The instructions displayed whenever needed in order to make the
usage more easily. We are proud of our project that it has current
relevance. We liked the project very much. This project helps us to get
more idea about writing simple or elementary game programs. It helps
us to improve the understanding about various concepts of c++
language and its usage in accurate circumstances