Exforsys

Online Training

dice program.....

This is a discussion on dice program..... within the Shell Programming forums, part of the Operating Systems category; having difficulty with this please help with code if anyone can. ____________________________________ Write a script that plays a ‘double or ...


Go Back   Exforsys > Operating Systems > Shell Programming

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-21-2006, 08:22 PM
Junior Member
 
Join Date: Feb 2006
Posts: 1
riverrock is on a distinguished road
dice program.....

having difficulty with this

please help with code if anyone can.

____________________________________

Write a script that plays a ‘double or nothing’ game. The rules are: a bet is laid and the dice is rolled. If it’s an even number you win double the bet.

If it's odd you lose the lot. The program should allow the user to play as many times as they like. Make sure you keep the user informed all the time as to how much they are winning/losing.



The dice roll can be done using the following code:



Declare an integer variable called dice.

typeset –i dice



and in the code:

((dice=RANDOM%6+1))



This assigns to dice a random number value between 1 and 6 inclusive.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:40 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.