Question
HiLo Guessing Game and High-Score Keeping (IN C++) This assignment utilizes: - random numbers - loops - conditional statements - basic I/O - file I/O
HiLo Guessing Game and High-Score Keeping (IN C++)
This assignment utilizes:
- random numbers
- loops
- conditional statements
- basic I/O
- file I/O
- maintaining sorted data
Part 1
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! What is your name?
Dirty Dan
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 Dirty Dan!
That's a very good score...
Part 2
Now implement a high-score record keeping system. The idea is that each time you play (run the program), your name and score should be recorded in a high-score file (at least if you scored in the top ten). At the start of each run, the game should list the top 10 best scores of anyone that has ever played your game.
Here is a sample run:
Welcome to the number guessing game. The top 10 best scores so far are:
Ed Sheeran 4
Camilla Cabello 4
G Easy 5
Dirty Dan 6
Lil Pump 7
Post Malone 7
Cardi B 9
Dua Lipa 12
Portugal Theman 20
Demi Lovato 53
Think youve got what it takes to make the top ten? Lets find out!
What is your name?
Bebe Rexha
Guess a number between 1 and 100
(etc)
It took you 10 guesses Bebe Rexha!
Not too shabby, but not too good either...
Hey, you made the top 10! Congratulations!
(end program)
The next time the program is run, the following should be displayed. Note that Bebe is now in the top 10, and Demi has been bootedoff.
Welcome to the number guessing game. The top 10 best scores so far are:
Ed Sheeran 4
Camilla Cabello 4
G Easy 5
Dirty Dan 6
Lil Pump 7
Post Malone 7
Cardi B 9
Bebe Rexha 10
Dua Lipa 12
Portugal Theman 20
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started