Write a cpp program to play a simple version of dice game

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

Assignment

This assignment will use: while loops, for loops, if else blocks, basic arrays, random numbers, and boolean values.

In this homework assignment you will write a c++ program to play a simple version of the dice game, Yahtzee. The object of Yahtzee (or our simple version), is to roll 5 dice with the purpose of getting all 5 dice to show the same number.

Store your 5 dice as an int array of size 5. Use rand()%6+1 to get a random dice value between 1 and 6. After your first roll of the dice, print the dice values to the screen, and ask the user which number they would like to hold. To get all dice the same number, the user will "hold" all the dice of one number, and roll the other dice to try and get them to be the same number.

For example, if the dice read 5 5 2 4 1, it is the best strategy to hold the two 5 dice, and re-roll the 2 4 and 1. Then, in the dice array, 2 4 1 will be regenerated with random values between 1 and 6. Eventually all dice will be a 5, and you have a Yahtzee! After the user gets a Yahtzee, display to the screen which number they got a Yahtzee with, and how many turns it took to get a Yahtzee.

After displaying the results of the Yahtzee game, ask the user if they would like to play again. If the user enters a ‘y', play the game again. If the user enters anything else, end the program.

Use a while loop to play the game over and over, if the user enters a ‘y' to play again. Use a while loop to roll the dice while you are trying to get a Yahtzee. Use for loops to generate the random dice values, and print the dice to the screen after each turn. Use booleans where appropriate (like to control the while loops), and ints and chars where appropriate

Sample Console Output:
Welcome to Yahtzee!!!
Here is your first roll:
5 5 2 4 1
Pick a number to hold (usually the number with the most dice): 5
Here is your roll:
5 5 1 5 1
Pick a number to hold (usually the number with the most dice): 5
Here is your roll:
5 5 5 5 5
You got a yahtzee!! with the number 5, in 3 turns
Would you like to play again?(y/n) y
Welcome to Yahtzee
Here is your roll:
4 3 6 6 2
Pick a number to hold (usually the number with the most dice): 6
Here is your roll:
5 1 6 6 5
Pick a number to hold (usually the number with the most dice): 6
Here is your roll:
4 4 6 6 6
Pick a number to hold (usually the number with the most dice): 6
Here is your roll:
6 6 6 6 6
You got a yahtzee!! with the number 6 in 4 turns
Would you like to play again?(y/n) n
Have a great day!

Code Style and Naming Conventions:

You need to follow the style and naming conventions used in class. Name variables with good descriptive names, and give proper spacing and indentation to your code to make it easy to follow. Add good comments to your code, that explain what your program does.

Reference no: EM131519901

Questions Cloud

Relationship of initial public offerings : What is the relationship of initial public offerings and the stock market? Please cite so I can find the information.
Prepare an accrual-basis income statement : Horned Frogs Fine Cooking maintains its books using cash-basis accounting. However, the company recently borrowed $50,000 from a local bank
Describe the theories of jung and gardner : Instructions: Write a 750-1000 word essay using the theories of Jung and Gardner to describe your top three strengths
How can the article apply to organizations : How can the article be applied in your day-to-day activities regarding information security? How can the article apply to organizations, not just individuals?
Write a cpp program to play a simple version of dice game : In this homework assignment you will write a c++ program to play a simple version of the dice game, Yahtzee. This assignment will use while loops and for loops.
What is the problem being addressed by your research study : What is the problem being addressed by your research study? What are your independent and dependent variables? What are their operational definitions
Depreciation on the equipment for the given year : The information necessary for preparing the 2012 year-end adjusting entries for Bearcat Personal Training Academy appears below.
Which values remained the same and why : Which values changed and why? Which values remained the same and why? What is the page cache? What are page tables? What is resident memory?
Prepare the year-end adjusting entries : Jaguar Auto Company provides general car maintenance to customers. The company's fiscal year-end is December 31. The December 31, 2012, trial balance.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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