Computer Science Canada Help making bulletproof turing program |
Author: | ThePress_Dog [ Wed Nov 02, 2011 8:26 am ] |
Post subject: | Help making bulletproof turing program |
Hi! I was given an assignment by my teacher to make a simple Turing program, but it has to be bulletproof. I have to get 2 numbers from the user and output the sum and product however, it cannot crash if the user enters a alphabetic value. Here is my code so far var num1, num2 : real loop put " Choose a number, any number. " get num1 put " Again, enter a number different from the first. " get num2 put " The sum of your two numbers are : ", num1 + num2, " The product of your numbers are " , num1*num2 end loop as you can see it is simple, but i cannot find the functions/ don't know how to use them to make this bulletproof (PS this is my first year of Programing) Thank you. |
Author: | Nick [ Wed Nov 02, 2011 8:30 am ] |
Post subject: | RE:Help making bulletproof turing program |
Look into strint and strintok. Also you may also need to declare a couple temp variables. |
Author: | ThePress_Dog [ Wed Nov 02, 2011 8:35 am ] |
Post subject: | Re: Help making bulletproof turing program |
I don't know where to put the functions either, and how to declare a temporary value, we only learned the built in functions yesterday. |
Author: | md [ Wed Nov 02, 2011 8:54 am ] |
Post subject: | RE:Help making bulletproof turing program |
Why is this not in one of the Turing forums? |
Author: | ThePress_Dog [ Wed Nov 02, 2011 8:56 am ] |
Post subject: | Re: Help making bulletproof turing program |
Because i am an absolute noob at this site ![]() |
Author: | tg851 [ Wed Nov 02, 2011 10:41 am ] |
Post subject: | RE:Help making bulletproof turing program |
look into ord and chr for turning numbers into characters and vice-versa |
Author: | Velocity [ Sun Nov 06, 2011 1:21 pm ] |
Post subject: | RE:Help making bulletproof turing program |
What do you mean by bullet proof? I may be able to help. |
Author: | Beastinonyou [ Sun Nov 06, 2011 3:40 pm ] | ||
Post subject: | Re: Help making bulletproof turing program | ||
by "Bulletproof", it's simply a term used to describe having a program not be able to be crashed by something a user does. In this case, he needs to ensure that when the user enters num1 and num2, they are in fact only integers. if they contain an alphanumeric value, it will crash. Use this to help solve your problem:
|
Author: | tg851 [ Mon Nov 07, 2011 11:21 am ] | ||
Post subject: | Re: Help making bulletproof turing program | ||
Beastinonyou @ Sun Nov 06, 2011 3:40 pm wrote: by "Bulletproof", it's simply a term used to describe having a program not be able to be crashed by something a user does.
In this case, he needs to ensure that when the user enters num1 and num2, they are in fact only integers. if they contain an alphanumeric value, it will crash. Use this to help solve your problem:
I broke it,some unicode characters can make it go nighty night,but still its pretty damn sturdy |
Author: | Zren [ Mon Nov 07, 2011 2:07 pm ] |
Post subject: | Re: Help making bulletproof turing program |
tg851 @ Mon Nov 07, 2011 11:21 am wrote: I broke it,some unicode characters can make it go nighty night,but still its pretty damn sturdy That has to do with limitations in Turing's character data type. It only accepts values in the ASCII range (0, 255). Strings are just arrays of characters, which is the data type use by the get statement. |