Write a program that will simulate a single game of craps

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

Loops and Symbolic Constants

Overview
For this assignment, write a program that will simulate a single game of Craps.
Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues.
If the sum of the first roll of the die is equal to 7 or 11, the player wins immediately.
If the sum of the first roll of the die is equal to 2, 3, or 12, the player has rolled "craps" and loses immediately.
If the sum of the first roll of the die is equal to 4, 5, 6, 8, 9, or 10, the game will continue with the sum becoming the "point." The object of the game is now for the player to continue rolling the die until they either roll a sum that equals the point or they roll a 7. If the player "makes their point," they win. If they roll a 7, they lose.
Basic Program Logic
The program will use the random number generator to simulate the rolling of the die. Therefore, the random number generator must be seeded. This is done one time in the program. Use any value for srand that you would like while developing the program - time(0) will give different results while an integer literal will produce the same results every time the program is run.
Next, roll the die by generating two random numbers between 1 and 6. The two numbers should be added together and the sum of the die should be displayed.
If the sum of the die is equal to 7 or 11, the game is over and the player has won. Display a congratulatory message.
If the sum of the die is equal to 2, 3, or 12, the game is over and the player has lost. Display a message indicating the player has lost.
For any other sum, the sum is now the point and the game should continue until the user rolls the point again or rolls a 7. One possible way to do this is:
• Save the sum (the point) in a variable so it can be used for a later comparison
• Display the point
• Create a variable and initialize it to a value of your choice to indicate that the game should continue.
• In a loop that executes as long as the game should continue:
o roll the die and display the sum
o if the sum of the die is the same as the point, display a congratulatory message indicating the player has made their point and they won the game. Also change the variable that controls the loop to indicate the game should no longer continue.
o otherwise, if the sum of the die is 7, display a message that the player has lost the game and change the variable that controls the loop to indicate the game should no longer continue.
Symbolic Constants
The program should use at least three symbolic constants. Some options are:
• an integer for each of the values (2, 3, and 12) that represents craps on the first roll of the die
• an integer that represents the value 7
• an integer that represents the value 11
Program Requirements
1. Make and use meaningful variable names.
2. Make sure to actually use the symbolic constants that are created.
3. Be sure to #include <cstdlib> and <ctime>
4. The program MUST be fully documented according to the documentation standards on the course website. Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does.
5. Make sure that the copy of the program that is handed in uses srand(8) to set the seed value for the random number generator.
6. Hand in a copy of the source code (CPP file) using Blackboard.

Reference no: EM131743111

Questions Cloud

Round to 3 decimal places as needed : Given P(A) = 0.98, P(B) = 0.21, P(C) = 0.04 and that events A, B, and C are independent, what is P(A, B, and C). Answer in decimal form.
Define who have been other dreamers in the evers family : Who have been other "dreamers" in the Evers family, and what were their dreams? Did they achieve their dreams
Round your answer for the test statistic : Round your answer for the test statistic to two decimal places and your answer for the -value to three decimal places.
International and multicultural marketing strategies : How do the three unique and uncontrollable variables in a global environmental scan impact international and multicultural marketing strategies?
Write a program that will simulate a single game of craps : CSCI 240 - write a program that will simulate a single game of Craps and The program will use the random number generator to simulate the rolling of the die
What roberts means by lucie initially being detribalized : What is your understanding of what Roberts means by Lucie initially being detribalized
Independent retailing and contractual systems : What are the pros and cons of independent retailing and contractual systems in the small business setting?
What is the risk- and quality-management tool : Explain the concepts of risk management in the health care industry. What is the risk- and quality-management tool? What is the purpose of the tool?
What is that maximum height : How long does it take for the ball to hit the ground? (Round your answer to two decimal places.)

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