Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with Craps Games
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
masternav




PostPosted: Tue Apr 26, 2005 8:44 am   Post subject: Help with Craps Games

I dont get how to follow how many games the user wants

LOOPING STRUCTURES

Problem

Write a program to simulate the game of Craps. In this game a player rolls two six-sided dice. The player wins or loses the game based on these rules:

First Roll

1. If the outcome is a 7 or 11 on the first toss the player wins outright.

2. If the outcome is a 2, or 12 on the first toss the player loses outright.

3. If the outcome is a 3, 4, 5, 6, 8, 9, or 10, the player gets to roll the dice again.

Second and Subsequent Rolls

1. The player keeps rolling the dice until the outcome matches the outcome of the first roll. If a 7 is rolled the game ends and the player loses.

Input

The program should ask the player how many games he/she wants to play.

Output

The output display should be similar to this.


Sample Input and Output

Enter the number of games to be played.
3
GAME 1
Roll 1: 11
YOU WIN!

GAME 2
Roll 1: 5
Roll 2: 8
Roll 3: 5
YOU WIN!

GAME 3
Roll 1: 9
Roll 2: 3
Roll 3: 4
Roll 4: 6
Roll 5: 7
YOU LOSE!

= = = = = = = = = = = = = = = =

SUMMARY OF GAMES

GAMES WON 2
GAMES LOST 1

WIN AVERAGE 66%
= = = = = = = = = = = = = = = =
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Tue Apr 26, 2005 1:49 pm   Post subject: (No subject)

You mean how many times the user plays? After he's finished him game, have him choose if he wishes to play another game, and if he does, play again, and have a counter keep track of how many games the user's played, and how many wins/losses.
masternav




PostPosted: Tue Apr 26, 2005 2:45 pm   Post subject: (No subject)

yes can someone help me with that
jamonathin




PostPosted: Tue Apr 26, 2005 5:12 pm   Post subject: (No subject)

It's called, do your work, try it for yourself, and ask for pointers.
Vertico




PostPosted: Tue Apr 26, 2005 5:20 pm   Post subject: (No subject)

just use a var to keep track off how many games have been played. when it reachs whatever the amount of games the user said(= the var used to get how many games), have it exit the loop and display the final result.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: