Allow single play a simple two dice game of chance against

Assignment Help C/C++ Programming
Reference no: EM13166817

Program Specication:

Write a program that allows a single Player (the user) to play a simple two dice game of chance against

"The Odds".

Game Description:

There is a single player, with two six sided die.

The sides of each die are labeled with the numbers from 1 to 6, we will call this the value of the die.

A game is made up of rounds, a single round is played as such:

1. The player rolls their two dice.

d1 = (int)(Math.random() * 6) + 1;

d2 = (int)(Math.random() * 6) + 1;

d1, d2 declared as type int before the game loop.

2. The dice are displayed, in some reasonable format.

3. A determination is made as to whether or not the player won the round, this determination is

made via the following rules:

{ A Pair is when both dice have the same number on their top faces. If the player has any

pair then they win the round.

{ A Straight is when both dice have a dierent number on their top faces - but they are

consecutive numbers. If the player has any Straight then they neither win nor lose the

round.

{ A Junker is then anything that is not a Pair or a Straight. If the player has any Junker

then they lose the round.

4. The result of the round (with respect to the Player) is reported.

The player is asked if they wish to play another round.

Once the player indicates that they do not wish to play another round: Before exiting, the program

displays a short report stating how many rounds were played, of those - how many were won and

how many were lost.

 

Sample run(s):

Welcome to Computer Dice

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

You will first roll your dice

Next the outcome of your roll will

be determined:

any Pair and you Win

any Straight and you just roll again

anything else and you Lose

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

Player

--------

5 1

Sorry, you lose!

Do you wish to play again [y, n] : 5

Do you wish to play again [y, n] : yes

Do you wish to play again [y, n] : y

Player

--------

2 6

Sorry, you lose!

Do you wish to play again [y, n] : y

Player

--------

4 4

Congrats, you win!

Do you wish to play again [y, n] : y

Player

--------

3 2

Its a tie!

Do you wish to play again [y, n] : y

Player

--------

2 3

Its a tie!

Do you wish to play again [y, n] : n

Computer Dice Results

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

You played 5 rounds

Rounds won : 1

Rounds lost : 2

 

 

Reference no: EM13166817

Questions Cloud

How many groups could be formed : A dancehall contains 173 men and 238 women. A certain "promenade" calls for the formation of groups, with each group consisting of one man with two women. a)How many groups could be formed? b) which sex is in excess? By how much? (show calculation..
List and describe at least three prokaryotic cellular featur : List and describe at least three prokaryotic cellular features that could be targeted in this way to inhibit or kill a bacterial pathogen.
Distinct integers that has the following property : You have an array A[0], A[1], ..., A[n - 1] of distinct integers that has the following property:The values in the array increase up to index p for some p between 0 and n - 1, and then decrease for all indices beyond p through positio
How many possible isomers could exist for diacetylferrocene : How many possible isomers could exist for diacetylferrocene? Explain. Calculate the volume of 3M aqueous sodium hydroxide needed to neutralize the acetic and phosphoric acids in the synthesis of acetylferrocene?
Allow single play a simple two dice game of chance against : Write a program that allows a single Player (the user) to play a simple two dice game of chance against
What is the osmotic pressure of a solution : What is the osmotic pressure of a solution made from dissolving 85.0g of glucose in 800ml of water at 19.0 C.
Assume an n × n matrix a is given : Assume an n × n matrix A is given, containing only 1's and 0's, such that, in each row, all 1's come before all 0's. Give an O(n log n) algorithm to count all 1's in A.
Using virtual methods, organize the animals : Using virtual methods, organize the animals in a small zoo, having as guests lions, parrots, alligators, penguins, elephants, cobras, zebras, hawks, turkeys and rabbits.
What percentang of water was in the hydrate : a 5.0 g sample of a hydrate of CaCl2 was heated, and only 4.3 g of the anhydrous salt remained. what percentang of water was in the hydrate?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write song playlist class-object-oriented design principles

Write a song playlist class in C++ called "PlayList" using object-oriented design principles. The playlist should support the following ADT.The implementation should be based on an array of strings to store the song titles.

  The funtion should take as parameters

Write a function in c ++ that multiplies two functions. the funtion should take as parameters two fraction structures. Then, the function should multiply the two fractions and return the solution as a fraction structure.

  Program to generate 100,000 prime numbers

Write a POSIX C/C++ program to generate 100,000 prime numbers. Assume that the program will be run on a computer with 5 CPUs and that your goal is to have this program finish as quickly as possible.

  Program that displays the ball at a random

Write a C++ program that displays the ball at a random location and then makes the ball move down to the bottom of the screen. When the ball reaches the bottom of the screen, it should start these actions over again, appear-ing at another random l..

  Write a c function to convert gallons-quarts-pints and cups

Write a C function named liquid() that is to accept an integer number and the addresses of the variables gallons, quarts, pints, and cups.

  C program to calculate power loss in transmission line

Write program in C to calculate the power loss in transmission line with resistance of 0.05 ohms/mile. Calculate power loss if 500 kW of power is transmitted from power generation station

  Calculate the component voltages

Calculate the component voltages for the following series resonant RLC circuit

  Ruby implement primitive types

How does Ruby implement primitive types, such as those for integer and floating-point data?  3-What is the single most important practical difference between Smalltalk and C++?

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

  Create a 1-dimensional (1d) array

Write a program to create a 1-dimensional (1D) array that contains 15 characters and display to the screen a count of the occurrences of each of the vowels a, e, i, o, and u in the array.

  Assessment system of a university

Write a program for Assessment system of a University

  C program to solve the quadratic equation of rocket launch

Write a C program to solve the quadratic equation of rocket launch by computing the roots (t1 and t2) of that quadratic equation: gt2 + vt + l = 0 (or) for simplicity ax2 + bx + c = 0. Get the values of g, v, and l from the user. The program should d..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd