' DICE.BAS
' This program asks the user to enter how many times the QuickBASIC
'   Interpreter should "roll" two dice, and then calculates how many
'   times the number 7 comes up.

CLS

RANDOMIZE TIMER

COLOR 4             ' red color for title
PRINT "DICE-SIMULATION PROGRAM"
COLOR 7             ' restore default white color
PRINT
numSeven% = 0       ' start with 7 counter equal to zero

INPUT "How many times should I roll the dice?  ", rolls%
PRINT
PRINT "Working..."  ' make sure the user knows nothing is wrong

FOR i% = 1 TO rolls%
    die1% = INT(RND * 7)       ' "roll" the first die
    die2% = INT(RND * 7)       ' "roll" the second die
    IF die1% + die2% = 7 THEN numSeven% = numSeven% + 1
NEXT i%

PRINT
PRINT "Out of"; rolls%; "rolls, the number 7 came"
PRINT "up"; numSeven%; "times."

