I'm trying to create a sub-program for my dice roller but I'm at a loss for how to do this without a large number of If statements. If it matters this is the TI-84 Plus CE
What I currently have is basically supposed to be like "If X=(1, 2, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14, 15, 16, 17, 19, or 20) then do this else do that.
Currently what I have is this:
randInt(1,Y,1)→X
While not(getKey
If X=(1 or 2 or 3 or 4 or 5 or 6 or 7 or 9 or 10 or 12 or 13 or 14 or 15 or 16 or 17 or 19 or 20)
Then
Output(1,1,"You rolled a
Output(1,14,X
Else
Output(1,1,"You rolled an
Output(1,15,X
End
End
with Y being defined in the parent program.
When I run it without defining X beforehand the calculator defaults to 0 but doesn't run the random number gen. If I store a value into X that is in the list (such as 2) it seems to go to the Else regardless. ("You rolled an 2" gets displayed). I believe the biggest problem lies in my If statement. Because what I want it to do is to have it output "You rolled a 2" or "an 8" so that reading it feels natural.
Aucun commentaire:
Enregistrer un commentaire