REM
*************************************
REM *****
REM ******* ACSL Senior
Program 1 *******
REM ********** By Ryan Skvarla **********
REM
*************************************
DIM event$(1)
FOR times = 1 to 5
! *** cleaning everything up because it has
to loop 5 times
LET rb
= 0
MAT redim
event$(1)
LET output$ = ""
PRINT
INPUT PROMPT "# of selections: ": num
INPUT PROMPT "# of reds: ": red
INPUT PROMPT "# of blues: ": blue
INPUT PROMPT "# of whites: ": white
IF num = 1 then
PRINT "Event #"; str$(i);
INPUT event$(1)
ELSE
MAT redim
event$(num)
INPUT rep$
FOR i = 1 to
num
INPUT event$(i)
NEXT i
END IF
LET total = blue + red + white
LET notr = total
- red
LET notb = total
- blue
LET notw = total
- white
! *** 1 selection ***
IF num = 1 then
IF event$(1) = "R" then
LET output$ = str$(red) & "/" & str$(total)
ELSE IF event$(1) = "B" then
LET output$ = str$(blue) & "/" & str$(total)
ELSE IF event$(1) = "W" then
LET output$ = str$(white) & "/" & str$(total)
ELSE IF event$(1) = "r" then
LET output$ = str$(notr) &
"/" & str$(total)
ELSE IF event$(1) = "b" then
LET output$ = str$(notb) &
"/" & str$(total)
ELSE IF event$(1) = "w" then
LET output$ = str$(notw) &
"/" & str$(total)
END IF
! *** multiple
selections ***
ELSE
IF rep$ = "N" then ! no
replacement before next drawing
LET newtotal
= total ! denomination
of fraction
LET rbw =
1 ! numerator
of fraction
FOR i = 1
to num-1
LET newtotal
= newtotal * (total-i)
NEXT i
FOR i = 1
to num
IF event$(i)
= "R" then
LET rbw
= rbw * red
LET red = red -1
ELSE IF event$(i) = "B" then
LET rbw
= rbw * blue
LET blue = blue - 1
ELSE IF event$(i) = "W" then
LET rbw
= rbw * white
LET white = white - 1
ELSE IF event$(i) = "r" then
LET notr
= (total-i+1) - red
LET rbw
= rbw * notr
ELSE IF event$(i)
= "b" then
LET notb
= (total-i+1) - blue
LET rbw
= rbw * notb
! LET notb
= notb - 1
ELSE IF event$(i) = "w" then
LET notw
= (total-i+1) - white
LET rbw = rbw * notw
! LET notw
= notw - 1
END IF
NEXT i
LET output$ = str$(round(rbw)) & "/"
& str$(newtotal)
ELSE IF rep$ = "Y" then
LET rbw = 1
LET newtotal
= 1
FOR ct = 1 to num
LET newtotal
= newtotal * total
NEXT ct
FOR i = 1
to num
IF event$(i)
= "R" then
LET rbw
= rbw * red
ELSE IF event$(i) = "B" then
LET rbw = rbw * blue
ELSE IF event$(i) = "W" then
LET rbw
= rbw * white
ELSE IF event$(i) = "r" then
LET rbw
= rbw * notr
ELSE IF event$(i) = "b" then
LET rbw
= rbw * notb
ELSE IF event$(i) = "w" then
LET rbw
= rbw * notw
END IF
NEXT i
LET output$ = str$(round(rbw)) & "/"
& str$(newtotal)
END IF
END IF
PRINT
PRINT output$
NEXT times
END