Ask C/C++ Expert


Home >> C/C++

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

 

 

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9456935

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As