Sharp EL-5230 Calculator User Manual


 
106
Digital dice
This program simulates rolling of multiple dice. You can
play a dice game without dice or where there is not
enough space to roll dice.
At the first stage, ask the number of dice to use for play. Secondly, roll dice
and display the result and wait until any key is pressed.
1.
Press b 2 1 0 to open a window for creating a NEW program.
2. Type DICE for the title then press e.
•A NEW program called ‘DICE’ will be created.
3. Enter the program as follows.
Program code Key operations
Print”NO OF DICE i 1 @ a NO s OF
s DICE ; e
Input N i 2 ; N e
Label PLAY
i 6 @ a PLAY ; e
M=1 ; M ; = 1 e
X=0 ; X ; = 0 e
Label ROLL
i 6 @ a ROLL ; e
X=X+r.dice ; X ; = ; X + @
w 1 e
M=M+1
; M ; = ; M + 1 e
If M<=N Goto ROLL i 8 ; M i E ; N
; s i 9 @ a
ROLL ; e
Print X i 0 ; X e
Wait i 3 e
Goto PLAY
i 9 @ a PLAY ; e
Running the program
4. Press j to return to the PROG mode menu.
5. Press 0, select the program ‘DICE’ and press e.
6. Enter the number of dice to play and press e.
7. Press e (or any other key) to continue to play. Press j to quit.
Chapter 8: Application Examples