A player rolls two dice. Each die has six faces. These faces contain 1,2,3,4,5 or 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 and the house wins. If the sum is 4,5,6,8,9, or 10 on the first throw, then that sum becomes the player's point. To win, he must continue rolling the dice until he "makes his point", i.e. rolls the same sum again. If the player rolls 7 before making the point, he loses.

  • Write a function int rollDie( void) to simulate the rolling of a six sided die.
    • function should return a random number between 1 and 6
  • Write a function int firstRoll ( void) to simulate the first roll.
    • Function should call rollDie two times.
    • It should then return 0 for a winning roll
    • It should return -1 for a losing roll
    • It should return the total roll value for non-winning non-losing rolls
  • Write a function int makePoint ( int point) to simulate the later rolls.
    • Function should get as input the "point" to be made
    • It should then return -1 for a losing roll
    • It should return 0 for non-winning non-losing rolls
    • It should return 1 for a winning roll
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.