Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++ Declare an integer variable and initialize it to 100. This variable represents the number of points each player starts the game with. 3.

IN C++

Declare an integer variable and initialize it to 100. This variable represents the number of points each player starts the game with. 3. Declare an enumeration constant with values displayLeft, displayRight, Guess, Change and Exit (in order) and assign integer values 1 to 5 to them respectively. These five items will correspond to the menu choice you will provide the player. 4. Using a suitable message, ask the player for the name of the player. The name may have multiple words. Only alphabets (A-Z or a-z) and whitespaces are permitted in the account name. o If the player enters any other characters in the name, you need to generate an error message and ask for the name again. o Your program must keep on asking the player to enter the name until the player enters it correctly. The player may type the name in either uppercase or lowercase, but you need to convert every initial to uppercase and every other alphabet to lowercase. 5. Generate two seeded random integers in the range of 100 to 200, inclusive. The first integer MUST BE less than the second integer. Using a loop of choice, keep on generating the integers until it is so. 6. Declare two integers and initialize them with -1 and display them. Since you cannot display the actual numbers being randomly generated, you will only display these integers. In case, the player wants to see the randomly generated integer, you will replace one of the -1 with the actual random number being generated. 7. Based on the enumerated constant data of Step 3, generate menu choice for the player. Using an integer variable, ask the player to select from the menu. See Sample Output. 8. Design a switch-case block with a default case, use the enumerated data constants of Step 3 as your cases. Based on the player input of Step 7, one of the cases will execute. You must use a variable of your enumeration constant type as the switching expression. If the player chooses to display the integer on the left (the lower bound), display the first randomly generated integer instead of -1 on the left. o Provide a message saying a correct guess will only earn 1 point and an incorrect guess will lose 10 points in the game. If the player chooses to display the integer on the right (the upper bound), display the second randomly generated integer instead of -1 on the right. o Provide a message saying a correct guess will only earn 1 point and an incorrect guess will lose 10 points in the game. In both cases, make sure the player cannot display both numbers/bounds. If the player chooses to guess a number between the two bounds, ask the player to enter the guess. o If the guessed number is between the two bounds (i.e. the player guess correctly), increment the points, otherwise decrement the points. o If the player has displayed either of the two bounds, you need to increment by 1 point and decrement by 10 points, when appropriate. o If the player has NOT displayed any of the two bounds, you need to increment by 5 points and decrement by 5 points, when appropriate. o Update the player with the points balance after every guess. o Note that the guess CANNOT be the two bounds, it has to be strictly between the bounds to be a correct guess. For example, if the generated numbers are 150 and 160, both 150 and 160 are incorrect guesses. If the player chooses to change the random numbers, regenerate the two seeded random numbers, still making the first number smaller than second number. Deduct 1 point for this choice and provide the player updated points balance. If the player choose to Exit, display a suitable goodbye message using the name of the player and display the final points balance. If the player enters a wrong choice, use the default case to provide an error message and ask the player to enter again. 9. You must use a suitable loop of choice to allow the player to repeat Steps 7 and 8 i.e. choosing from the menu and executing the corresponding case, until the use chooses to Exit or the points balance falls below zero (becomes negative).

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

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

What are the three stages of a civil trial? Discuss each stage.

Answered: 1 week ago

Question

3. You can gain power by making others feel important.

Answered: 1 week ago

Question

Write down the circumstances in which you led.

Answered: 1 week ago