Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Core Ios Developer S Cookbook Core Recipes For Programmers

Authors: Erica Sadun ,Rich Wardwell

5th Edition

0321948106, 978-0321948106

More Books

Students also viewed these Programming questions

Question

Find dy/dx for the following functions. y = x sin x / 1 + cos x

Answered: 1 week ago

Question

9.1 Define a budget. How is a budget different from a forecast?

Answered: 1 week ago