Question: Refactor the Guess Number application we did in chapter 4 so that you move the logic into functions named get_random_number(), get_user_guess() and check_guess(). Use your

Refactor the Guess Number application we did in chapter 4 so that you move the logic into functions named get_random_number(), get_user_guess() and check_guess(). Use your best judgement to decide what code to move into which function. Again, create a hierarchy outline (see pg. 249) for the program and place it in the comments section at the top of the app. Its not required to break the functions out into header/implementation files, but you can if you like. Your choice.

Guess number program from chapter 4

#include #include #include

using namespace std;

int main(){ int upper_limit = 100; //Print the title de program and instructions cout cout //get the random number 1 and the the upper limit srand(time(nullptr)); int number = rand() % upper_limit; ++number;

// Only to test the program //cout

//Try until the user guesses what the random number is int count = 1; int guess = 0; while (guess != number){ cout cin >> guess;

if (guess upper_limit){ cout }else if (guess cout }else if (guess > number + 10){ cout }else if (guess cout }else if(guess > number){ cout }else{ cout } ++count; } cout }

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 Programming Questions!