Question: HiLo Guessing Game The program is in C++. This assignment utilizes: - random numbers - loops - conditional statements - basic input/output Write a program

HiLo Guessing Game

The program is in C++.

This assignment utilizes:

- random numbers

- loops

- conditional statements

- basic input/output

Write a program to play the Hi-Lo guessing game! In particular, your program should:

Generate a random number from 1 to 100.

Ask the user to guess the number

If the user is right, the game ends

If the user's guess is too high or too low, the program informs the user of that fact and asks for another guess.

This repeats until the user gets the number correct.

Further, your program should keep track of how many guesses the user takes to get the number right. An appropriate insult/compliment should then be issued to the user. For example:

11 or more "What a terrible score!..."

9-10 "Not too shabby, but not too good either...

7-8 "That's pretty good but you can do better..."

5-6 "That's a very good score..."

0-4 "Amazing! Or was it luck?"

Here is a sample run:

Lets play a Number Guessing Game!

Guess a number between 1 and 100

40

Too low!!

Guess a number between 1 and 100

90

Too high!!

Guess a number between 1 and 100

60

Too high!!

Guess a number between 1 and 100

50

Too low!!

Guess a number between 1 and 100

55

Too low!!

Guess a number between 1 and 100

56

You win!!

It took you 6 guesses.

That's a very good score...

Some Help (random numbers): To generate a random number from 1-10 in c++, do the following:

First, seed the random number generator. To do this, add #include to the top of your program, and add the following command:

srand(time(0));

Now use rand() to generate pseudo random numbers. Each call to rand() will generate a giant random number. Take the result and get the remainder of this giant number modulus 10 using rand() % 10. The remainder of any number when divided by 10 will be a number from 0 to 9. Take the result and add 1 to it to get a number from 1-10:

srand(time(0));

int x1 = rand() % 10 + 1; //will be something like 4

int x2 = rand() % 10 + 1; //will be something like 1

int x3 = rand() % 10 + 1; //will be something like 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!