I wrote a basic slot machine program on TI-83 but I can't keep people from putting in fractions of a dollar. Is there any way to test if an input is a whole number or limit input to whole numbers?
Date: 19 Apr 2015 21:43
Number of posts: 5
RSS: New posts
There is definitely a way to validate user input as described here.
If you are using Input or Prompt, you can continue to request the person for a valid input with the following pseudocode:
Repeat A>0 and not(fPart(A Input "DOLLAR:",A End
If you are doing a custom user input such as getKey or a menu, you could use the arrow keys to increment or decrement the values.
Or if you want to round to the nearest dollar:
Input "Dollars:",A If fpart(A)>.5: 2ipartA->A If fpart(A)<.5: ipartA->A //rest of code
I'm sure there is a better way to do this, but this is pretty simple
To do an arrow selection:
1->A Repeat K=105 If A<1:1->A Output(5,8,A) getkey->K A+(K=25 or K=26)-(K=34 or K=24)->A End //rest of code
That makes the up arrow or the right arrow increase it by 1. And the left or down arrow decrease it by 1. The enter key will select that value. It also prevents values less than 1.
live the life because the life is good —vivir la vida, porque la vida es buena
Vie la vie que la vie est bonne quod est bonum vitae in vita
lebe das Leben, weil das Leben ist gut —vivere la vita, perché la vita è buona