Question: In C + + Please Declare an integer variable and initialize it to 5 0 . This variable represents the number of points each player

In C++ Please
Declare an integer variable and initialize it to 50. This variable represents the number of points each player starts the game with.
Declare an enumeration constant with the values ADD, SUBTRACT, DISPLAY, GIVEUP 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.
Using a suitable message, ask the player for the username of the player. The name may have multiple words.
Only alphabets (A-Z or a-z), numeric characters (0-9) and whitespace are permitted in the username.
If the player enters any other characters in the username, you need to generate an error message and ask for the name again.
Your program must keep on asking the player to enter the name until the player enters it correctly.
Generate a suitable welcome message using the username.
Generate two seeded random integers in the range of 50 to 100, inclusive. These random numbers will be used to compute the sum and/or the difference later. The first random integer MUST BE less than the second random integer. Using a loop of choice, keep on generating the integers until it is so.
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. 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 be executed.
If the player chooses to ADD the two random numbers
Using a suitable message, ask the user to guess the sum of the two random numbers.
It is very hard to guess the exact sum, so we will provide a margin of error. If the absolute difference between actual sum and guessed sum is less than 5, we will take it as a correct guess. For example, if the randomly generated numbers are 70 and 60, and the user guessed 132, it is a correct guess. If the player guessed 128, it is also a correct guess. But if they guess 125, it is NOT a correct guess.
Increment points by 5 for a correct guess and provide updated points value. If the guess is correct, ask if the user wants to play another game. If the player wants to play another game, generate another set of two random numbers and restart the game.
Decrement points by 1 for an incorrect guess and provide updated points value.
If the player chooses to SUBTRACT the two random numbers
Using a suitable message, ask the user to guess the absolute difference between the two random numbers.
It is very hard to guess the exact sum, so we will provide a margin of error. If the absolute difference between actual difference and guessed difference is less than 5, we will take it as a correct guess. For example, if the randomly generated numbers are 70 and 60, and the user guessed 6, it is a correct guess. If the player guessed 14, it is also a correct guess. But if they guess 5, it is NOT a correct guess.
Increment points by 5 for a correct guess and provide updated points value. If the guess is correct, ask if the user wants to play another game. If the player wants to play another game, generate another set of two random numbers and restart the game.
Decrement points by 1 for an incorrect guess and provide updated points value.
If the player chooses to DISPLAY the first random number.
Deduct points by 3 as the cost for displaying the number.
You need to make sure the only the first random number gets displayed, and the
player is deducted points only once for the displaying it. If the user chooses to display again, provide suitable error message.
If the player chooses to GIVEUP
Display both random numbers with a suitable message.
Ask if the user wants to play another game. If the player wants to play another
game, generate another set of two random numbers and restart the game.
If the player chooses 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.
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 user chooses to EXIT or the points balance falls below zero (becomes negative). Note that the player may also choose to stop the game after making the correct guess.
In C + + Please Declare an integer variable and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!