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

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




PostPosted: Sun May 01, 2005 2:14 pm   Post subject: Game of Craps please read this

I made this game of craps im not sure if it is right or wrong can you people please test it and post reply how can I make it better, or what should I take out of the program. Thx, this is the beta so there for I didnt add colours or locates.
code:


put "Game of Craps"
var gamenum, die1, die2, won, lost : int
var avg : real
put "Please Enter the number of games you want to play "..
get gamenum
won :=0
lost :=0
for game : 1..gamenum
put "Game ", game
randint (die1, 1, 6)
randint (die2, 1, 6)
for roll : 1..die1+die2
if die1+die2 =7 or die1+die2= 11 then
put "You won!"
won := won+1
exit
elsif die1+die2=2 or die1+die2=12 then
put "You lose "
lost := lost + 1
exit
end if
randint (die1, 1, 6)
randint (die2, 1, 6)
put "Roll ", roll, ": ", die1+die2
end for
end for
put "======================================"
put "Summary of Games"
put skip
put "Games  Won: ", won
put "Games Lost: ", lost
put skip
avg := won*100/(won+lost)
put "Win Average ", avg : 10 : 2, "%"

Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon May 02, 2005 8:57 am   Post subject: (No subject)

For one it doesn't actually work...I believe there is a tutorial floating around in the Tutorials section that deals with this kind of thing.

One suggestion.
code:

    for roll : 1 .. die1 + die2


What is this line supposed to do? Think about what the loop is doing...you have a series of checks, none of which relate back to the variable 'roll'. So, what's the use of doing the same check that many times?
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  [ 2 Posts ]
Jump to:   


Style:  
Search: