random number guessing game with while loops create a program (or adapt the guessing game program that's posted in moodle a couple of weeks ago) that asks the user to guess a random number between one and sixteen, and compares their guess with the computer's number. save this program as guessLoops.cpp The program should display one of four messages: if your guess is higher than the computer's number: "Your guess is too high." if your guess is lower than the computer's number: "Your guess is too low." if your guess is the same as the compu

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

/*random number guessing game with while loops
create a program (or adapt the guessing game program that's posted in moodle
a couple of weeks ago) that asks the user to guess a random number between one and sixteen,
and compares their guess with the computer's number.
save this program as guessLoops.cpp
The program should display one of four messages:
if your guess is higher than the computer's number: "Your guess is too high."
if your guess is lower than the computer's number: "Your guess is too low."
if your guess is the same as the computer's number: "That is correct!"
if your guess is less than one or greater than sixteen: "Invalid guess."
If it's the last one, invalid guess, prompt the user, by using a loop, to guess again.
If your guess is too high or too low, ask the user if they'd like to guess again (if the
answer is 'y' for yes, repeat the statements that asks for a guess.
Then, repeat statement on line #6-#9 above.
If the answer is 'n' for no (meaning the user doesn't want to guess again),
display an ending statement, like
"Thanks for playing." and end the program.
test your program;

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr