Introduction The program generates a random number between 0 and 20 and asks the user to guess it. Program loops until the user guesses the correct answer. Additional specifications are shown in blue text 12. Random Number Guessing Game Write a program that generates a random number between 1 and 100 and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high. Try again." If the user's guess is lower than the random number, the program should display "Too low. Try again." The program should use a loop that repeats until the user correctly guesses the random number. Then the program should display "Congratulations. You figured out my number." Ensure that the user enters numeric input Keep track of the number of attempts and display it back at the end of the program when the user guesses the correct answer. Do not add to number of attempts when input is not numeric. Use loops for the data validation. You may use do-while or while loops. Click here to see document that demonstrates usage of loops to check numericity of input. Tasks to be completed Download ch5_lab2_incomplete.cpp from BlackBoard. Alternatively, you may copy the code from this document Rename the document as per the Programming Standards document Make the following changes to the program: O Code loop around lines 22-23 to ensure that user enters numeric input o Place condition in line 28 to ensure that loop is iterated as long as user input does not match the computer generated number. O Code loop around lines 36-37 to ensure that user enters numeric input O Refer to the Programming Standards document and follow the rules stated there in order to complete the program. Sample output from my implementation of the Assignment User input is shown in highligitted in yellow: I am thinking of a number between 1 and 20. Enter your guess : lkjf Enter your guess : Bjasf Enter your guess : kjf Enter your guess : 10 10 is too high. Try a smaller number. Enter your guess : 1ksjdf Enter your guess : 5 5 is too high. Try a smaller number. Enter your guess : 1 Congratulations. My number was 1. It took you 3 attempts! Secure network with SASE Read our e-book to learn about the 10 requirements of an effective SASE offering. Palo Alto Networks ... TT BOO 5 1 include
2 #include 3 #include 4 using namespace std; 7/ Needed to use random numbers 1/ Needed to call the time function 6 int main() - 7.1 const int MAX_NUM = 20; // The maximum random value used int computer Num. // The computer's randomly generated number guess: 1/ user's guess Te // Seed the random generator and get a random integer between 1 and MAX_NUM 16 srand(time()): computer Num = rand() % MAX_NUM + 1; // Explain the game and get the user's first guess cout > guess: cout computer Num) cout > guess: 11 We get here when the loop is exited, which means the user has // guessed correctly. so display a congratulatory message. cout