Implement a craps game according to the rules

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

1. Learner Objectives:

At the conclusion of this programming assignment, participants should be able to:
* Apply repetition structures within an algorithm
* Construct while (), for (), or do-while () loops in C
* Compose C programs consisting of sequential, conditional, and iterative statements
* Eliminate redundancy within a program by applying loops and functions
* Create structure charts for a given problem
* Determine an appropriate functional decomposition or top-down design from a structure chart
* Generate random numbers for use within a C program

2. Prerequisites:

Before starting this programming assignment, participants should be able to:
* Analyze a basic set of requirements and apply top-down design principles for a problem
* Customize and define C functions
* Apply the 3 file format: 1 header file and 2 source files
* Open and close files
* Read, write to, and update files
* Manipulate file handles
* Apply standard library functions: fopen (), fclose (), fscanf (), and fprintf ()
* Compose decision statements ("if" conditional statements)
* Create and utilize compound conditions
* Summarize topics from Hanly & Koffman Chapter 4 & 5 including:
* What are counting, conditional, sentinel-controlled, flag-controlled, and end file-controlled loops
* What are while (), do-while (), and for () loops
* What is a selection or conditional statement
* What is a compound condition
* What is a Boolean expression
* What is a flowchart

3. Overview & Requirements:

The following description has been adopted from Deitel & Deitel. One of the most popular games of chance is a dice game called "craps," which is played in casinos and back alleys throughout the world. The rules of the game are straightforward:

A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2, 3, or 12 on the first throw (called "craps"), the player loses (i.e. the "house" wins). If the sum is 4, 5, 6, 8, 9, or 10 on the first throw, then the sum becomes the player's "point." To win, you must continue rolling the dice until you "make your point." The player loses by rolling a 7 before making the point.

Write a program that implements a craps game according to the above rules. The game should allow for wagering. This means that you need to prompt that user for an initial bank balance from which wagers will be added or subtracted. Before each roll prompt the user for a wager. Once a game is lost or won, the bank balance should be adjusted. As the game progresses, print various messages to create some "chatter" such as, "Sorry, you busted!", or "Oh, you're going for broke, huh?", or "Aw cmon, take a chance!", or "You're up big, now's the time to cash in your chips!"

Use the below functions to help you get started! You may define more than the ones suggested if you wish!

* void print_game_rules (void) - Prints out the rules of the game of "craps".
* double get_bank_balance (void) - Prompts the player for an initial bank balance from which wagering will be added or subtracted. The player entered bank balance (in dollars, i.e. $100.00) is returned.
* double get_wager_amount (void) - Prompts the player for a wager on a particular roll. The wager is returned.
* int check_wager_amount (double wager, double balance) - Checks to see if the wager is within the limits of the player's available balance. If the wager exceeds the player's allowable balance, then 0 is returned; otherwise 1 is returned.
* int roll_die (void) - Rolls one die. This function should randomly generate a value between 1 and 6, inclusively. Returns the value of the die.
* int calculate_sum_dice (int die1_value, int die2_value) - Sums together the values of the two dice and returns the result. Note: this result may become the player's point in future rolls.
* int is_win_loss_or_point (int sum_dice) - Determines the result of the first dice roll. If the sum is 7 or 11 on the roll, the player wins and 1 is returned. If the sum is 2, 3, or 12 on the first throw (called "craps"), the player loses (i.e. the "house" wins) and 0 is returned. If the sum is 4, 5, 6, 8, 9, or 10 on the first throw, then the sum becomes the player's "point" and -1 is returned.
* int is_point_loss_or_neither (int sum_dice, int point_value) - Determines the result of any successive roll after the first roll. If the sum of the roll is the point_value, then 1 is returned. If the sum of the roll is a 7, then 0 is returned. Otherwise, -1 is returned.
* double adjust_bank_balance (double bank_balance, double wager_amount, int add_or_subtract) - If add_or_subtract is 1, then the wager amount is added to the bank_balance. If add_or_subtract is 0, then the wager amount is subtracted from the bank_balance. Otherwise, the bank_balance remains the same. The bank_balance result is returned.
* void chatter_messages (int number_rolls, int win_loss_neither, double initial_bank_balance, double current_bank_balance) - Prints an appropriate message dependent on the number of rolls taken so far by the player, the current balance, and whether or not the player just won his roll. The parameter win_loss_neither indicates the result of the previous roll.
* Others?
* A main ( ) function that makes use of the above functions in order to play the game of craps as explained above. Note that you will most likely have a loop in your main ( ) function (or you could have another function that loops through the game play).

Have a great time with this assignment! There is plenty of room for creativity! Note: I have not stated how you must display the game play! You may do as you wish!

IV. Submitting Assignments:

Using the OSBLE+ MS VS plugin, please submit your solution. Please visit https://osble.codeplex.com/wikipage?title=Submitting%20an%20Assignment&referringTitle=VS%20Plugin for more information about submitting using OSBLE+.

Your project must contain one header file (a .h file), two C source files (which must be .c files), and project workspace.

Your project must build properly. The most points an assignment can receive if it does not build properly is 65 out of 100.

Reference no: EM131223708

Questions Cloud

Client pay the agency for the production : How much will the agency keep?The ad you ran cost $30,000 to produce. Your agency charges a 17.65 percent markup to the client for outside production costs. How much will your client pay the agency for the production? How much of that will your ag..
What are some of the issues that may impact : What are some of the contractor's responsibilities in establishing a quality assurance program? What are some of the issues that may impact the type and level of quality inspections they conduct?
Information on international franchising opportunities : Using any of the recognized search engines such as Yahoo or Google, find information on international franchising opportunities. Once you have found a franchising opportunity, collect data (franchise fees, working capital, equipment, initial inven..
Assumptions are you making with that statement : Would a rural community be able to afford a higher price? What assumptions are you making with that statement?
Implement a craps game according to the rules : CptS 121 - Program Design and Development - Write a program that implements a craps game according to the above rules. The game should allow for wagering. This means that you need to prompt that user for an initial bank balance from which wagers wi..
Probability that the number of voters : A candidate for public office is thought to have the support of 60% of the voters.  A random sample of 100 voters was gathered to verify this position.  Use the normal approximation of a binomial to answer the following questions.What are the expe..
Analyze whether just-in-time be implemented without kanban : Analyze the difference between a just-in-time system and a kanban system. Analyze whether just-in-time can be implemented without kanban. Explain why or why not in detail.
Daily output of a production line : The daily output of a production line varies according to a normal distribution with a mean (µ ) of 163 units and a standard deviation (σ ) of 3.5. Find the probability that the daily output will fall below 160 units.
Analyze the price of apples : Last week, Arnold purchased 3 apples at the store for $3.90. This week he purchased 5 apples for $6.50. Help Arnold analyze the price of apples. Write an equation, in slope-intercept form, that shows the relationship between the number of app..

Reviews

inf1223708

9/30/2016 9:38:40 AM

Hi Expertsmind, I'm extremely sad that it has taken me this long to Thank You for doing this paper. You sent it to me around (10) days prior - it was about utilizing Renewable Energy as a part of New Homes. Shockingly, I have been working around sixty hours for each week at my occupation and have not had sufficient energy to audit it as of not long ago. I checked it totally and observed it to be VERY GOOD. thanks

len1223708

9/28/2016 6:46:44 AM

Hey, you can reach my programming assignment down below ..This assignment is worth 100 points. Your assignment will be evaluated based on a successful compilation and adherence to the program requirements. We will grade according to the following criteria: * 90 pts for adherence to functional decomposition stated above (see the individual points above) * 10 pts for adherence to proper programming style established for the class and comments

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