Question: This assignment asks you to implement a guessing game as a C++ program. For this you need to familiarize yourself with variables, ifs (nested
This assignment asks you to implement a guessing game as a C++ program. For this you need to familiarize yourself with variables, ifs (nested and multiple ifs), random numbers, and loops. The program should do the following: Print a welcome message Repeat the following until the game is over indicated by user entering Q' or 'q'. o Select a random number between 1 and 20. o Ask the user to input a number between 1 and 20. o Check if the user input is equal to the generated random number. If they are equal then the user has won. Print appropriate message. If they are not equal then give the user a hint as to whether the user's entered number is greater or less than the random number and provide two more turns to the user giving the hint at each turn. (Total number of tries at guessing the generated random number is three (3)) Below is a screenshot of a working program: Scenario 1 A number has been randomly generated between 1-20 inclusive....Guess the number: 15 You have to go higher. You have 2 attempt (s) left A number has been randomly generated between 1-20 inclusive...Guess the number: 17 You have to go lower. You have 1 attempt(s) left A number has been randomly generated between 1-20 inclusive...Guess the number: 16 CONGRATULATIONS... You win :) Enter 'Y' to play the guessing game or 'Q' to quit
Step by Step Solution
3.45 Rating (161 Votes )
There are 3 Steps involved in it
code include include using namespace std int main char chY fo... View full answer
Get step-by-step solutions from verified subject matter experts
