Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you guess the computers number? We will follow a process to build a working program one at a time. A sample run of the

Can you guess the computers number? We will follow a process to build a working program one at a time. A sample run of the program follows. We will try to replicate its behavior exactly. Ive picked a random number from 1 to 100, try to guess it. Enter your guess: 50 Too high Enter your guess: 25 Too low Enter your guess: 37 Too low Enter your guess: 43 Too high Enter your guess: 40 You found it in 5 guesses! Building the program Write C++ code for each step of the process. 1. Setup your program with an empty main. 2. Add your include and using statements. 3. You need to have the computer pick a random number. If you include the random and chrono libraries the following code will genearte a random number from 1 to 100: std::default_random_engine generator(std::chrono::system_clock::now().time_since_epoch().count()); std::uniform_int_distribution distribution(1,100); int number = distribution(generator); 4. Initialize a variable guess that stores the users guess. You should deter- mine what it should be initialized too. 5. Write the start of a while loop that will continue as long as the user has not correctly guessed the answer. (Hint: this should use the variables defined in the first two steps.) 6. Write a line that will prompt the user for their guess and store it in guess. Make sure you store it as the correct type.

7. Write a block using conditionals that will tell the user if their guess was too high or too low. Note: you might need to change your answer to the previous questions. 8. Put the pieces together and run it. Test it to see if its what you have so far is working. 9. Add in code that counts the number of guesses and displays the final message to the user. Test and debug your program and submit your final version.

"Write the program in C++"

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_2

Step: 3

blur-text-image_3

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

Create an intervention for treating implicit racial bias.

Answered: 1 week ago