Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

Explain the meaning of the changing nature of HR practices.

Answered: 1 week ago