Question: Are you Even/ Odd? - Game Simulation Write a C++ program to simulate the following game: 1. The player has two dice to roll. 2.

Are you Even/ Odd? - Game Simulation Write a C++ program to simulate the following game:

1. The player has two dice to roll.

2. The numbers that are rolled on the dice are added and the sum (Sum1) is checked to see if it is even or odd.

3. If Sum1 is even, then the player gets one more chance to roll the dice.

a. After the player rolls the dice, the sum is generated again. Let us call it Sum2.

b. Now Sum2 is added with Sum1 and the total is checked to see if it is Even or odd.

i. If Even, the player won the game. Display appropriate message and display the total (Sum1+Sum2) as the Number of points earned.

ii. If Odd, the player lost the game. Display appropriate message. (Do not have to display points/total) 4. If Sum1 is Odd, the player lost the game.

Display appropriate message. (Do not have to display points/total) The player can repeat this game any number of times. Ask the player if he wants to play the game again. If yes, repeat, else stop. (Hint: Can use yor Y to represent yes and n or N to represent No.)

---------------------------------------------------------------------------------------------

A sample Run should look like this:

Rolling the Dice!!

Lets assume the dice reads, 2 and 4. Now Sum1 is 6, that means roll the dice again:

You got 2 and 4. The total is 6 and is even, so Hurray!! you get another chance! Rolling Dice Again!

You got 3 and 5. Total is 8 and grand total is 14!! Its even, therefore, you WON!!! Congratulations! You secured a total of 14 for this game!

Do you want to play again?

Y

Rolling the Dice!!

Lets assume the dice reads, 1 and 2. Now Sum1 is 3, which implies the player lost the game:

You got 1 and 2. The total is 3 and is odd. Sorry, you lost this game.

Do you want to play again?

N

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 Databases Questions!