Write a program that simulates the playing of this game

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

One of the most popular games of chance is a dice game known as "craps", played in casinos around the world. Here are the rules of the game:

A player rolls two six-sided die, which means he can roll a 1, 2, 3, 4, 5 or 6 on either die. After the dice come to rest they are added together and their sum determines the outcome.

If the sum is 7 or 11 on the first roll, the player wins. If the sum is 2, 3, or 12 on the first roll, the player loses (this is called "craps").

If the player rolls 4, 5, 6, 8, 9, or 10 on the first throw, then that becomes the player's "point". To win, the player must "make their point", that means that they must roll the sum they got on that first throw, so they keep rolling the dice. The player loses by rolling a 7 before making the point.

Part 1: The basic program

a) Write a flow chart or pseudo code for part 1 of the homework.

b) Write a C++ program that simulates the playing of this game with two players. You will need:

1. An introduction to your program with instructions and your name.

2. The players are prompted for a random number seed.

3. A function that generates the random numbers and prints the results to the interface. Two separate random numbers must be generated for the two die, not the sum. This function returns the toss of one die after the user is prompted to tap the spacebar.

4. The program alternates players rolling the die.

5. The program keeps track of the number of wins for each player.

6. The program tells the users if player 1 or 2 wins after 3 points are won.

7. Write the output to a file.

Part 2: Wagering

The program must ask the users if they want to gamble. This option will bypass a finite limit number of plays. Both players start with a bank balance of $1000 dollars.

Each turn, players are asked to enter a minimum wager of $100. If the player wins, the balance is increased by the wager, if they lose, it is decreased.

The program continues as long as the player has a positive bank balance, and they cannot wager more than is in the bank. When they lose, give a message like "Player X, you're busted!", and you can send other messages.

Reference no: EM132085635

Questions Cloud

Use logic expressions to represent essential statements : One day Lady Smith returned home and was surprised by a big birthday cake prepared by her three children, named Ada, Bob, and Chris.
The apple safari browser : The Apple Safari browser stands tall among all these browsers. Apple safari browser is present in all Apple devices.
Receive the broadcast : To what frequency must the homesick captain tune the ship's radio to receive the broadcast? (Round your answer to three significant figures.)
What is the speed of spacecraft b as measured by a : What is the speed of spacecraft B as measured by A? Express answer as a decimal fraction of c.
Write a program that simulates the playing of this game : Write a C++ program that simulates the playing of this game with two players.
Discuss about the search engine optimization : Which of the remaining three factors associated with semantic HTML is most important to semantic HTML, in your opinion?
What advantage does water have over rocks : Water and rocks are commonly used to store energy in solar heated buildings. What advantage does water have over rocks?
Create a one-liner program : Create a "one-liner" program. Every time someone hits your web site, they see a new one-liner (i.e. a one line phrase, sentence, etc.).
Latent heat of vaporization of water : How much water at 100?C could that much energy vaporize? The latent heat of vaporization of water is 2.26 × 106 J/kg. Answer in units of g.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program to meet the specifications of company

Using Visual Studio® and C# programming concepts, write a program to meet the specifications of the company's request.

  Menu with options to enter student information

Create a program that uses a menu with options to enter student information (name, ID, GPA), print student information, or quit the program. Use data files and FILE pointers to store and print information entered.

  Program to determine the smallest number out of 15 numbers

you are a mortgage broker who is determining whether you should provide a mortgage to perspective home purchasers. If you are willing to provide a mortgage, you need to decide how much you should charge the borrower

  Write and implement a cpp class which represents a book

Design and implement a C++ class which represents a Book, and use this class in a main program which reads in information for multiple books from a data file an

  Write a program to calculate the area of a circle

Write a program to calculate the area of a circle. The program should use two procedures. The first procedure will print out the program heading and ask the user to enter the radius. The second procedure should calculate the area. The area of the cir..

  How can the code be corrected?

In some of the compilers the integer division returns an integer and hence cannot be stored in a float variable and to correct this you need to change the second line here with "float x=1.0/a;". Adding ".0" to 1 will make a difference.

  Creating a part number

Write C++ program that asks a user to enter a part number to order. The rules for creating a part number are as follows:

  Write a c program for codeblocks that uses if else statement

Write a C program for codeblocks that uses if else statements(No switch) that declares 2 numbers as variables.

  Write program using c language to find page fault

Write program using c language to find page fault for individual processes, group of processes and system as whole using following system call int sys_pgfltstats(pid_t pid,int flag,pf_info_struct *info).

  Write a program named averages

Write a program named Averages that includes a method that accepts any number of numeric parameters, displays them, and displays their average.

  Write a program that allows the user to enter a tax bracket

How much higher the interest rate must be depends on the investor's tax bracket. Write a program that allows the user to enter a tax bracket .

  Program that computes the monthly loan payment

Write a program that computes the monthly loan payment, given the loan amount (a double value), the interest, as a percent % (a double value), and the number of years to repay the loan

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