Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a code in C++ that follows directions and answers each part. Your goal for this assignment is to exercise your knowledge of selection statements
Write a code in C++ that follows directions and answers each part.
Your goal for this assignment is to exercise your knowledge of selection statements (if else), looping constructs (while and for) and the use of rand(). Your game must adhere to the following interaction example Hold onto your pants, we're about to play guess-the-numbah! Pick a number between e and 100: 20 Too low! Not even close! Pick a number between e and 100: 75 Too high! Pick a number between e and 100: 63 Too low! 0ooh you're close! Pick a number between e and 100: 64 That's right! You won the game in 4 tries. Your game must use a random number between 0 and 100, inclusively. You should only accept guesses that are within the range [0, 100], showing an error message otherwise. Your game must print "Too low!" or Too high!" relative to the target number and the players' guess. Your game must print "Oooh you're closel" if the number guessed differs from the target by 5 or less, and it must print "Not even closel" if the number guessed differs from the target by a value of 25 or more For example, if the target is 50 and the player enters 10, your program should print "Too low!" and "Not even closel", but if the player enters 52, your program should print "Too high" and "Oooh you're closel". When the correct number is guessed, your program must print "You won the game in N tries" where N is the number of valid guesses the player made. Functional Requirements Define appropriate constants for the LOW (0) and HIGH (-100) limits of the game. Use these constants correctly. .Also, define appropriate constants for the TOO CLOSE_DIFFERENCE (5) and TOO_HIGH_DIFFERENCE (25) values. Use these constants correctlyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started