03-30-2016, 02:09 PM
Hey everyone. I'm having trouble coding something, figured I could get some help
basically it's an app that tests if the number I inserted is even or odd. The coding in GML goes as follows:
The app gets the number and divides it by two. If there are no remainders, it is even; and if there is a remainder, it is odd.
the exact problem i'm having is that currently, I am able to type a word and since GML considers words as "0", the app gives out the even message when it is clearly not even (it's not even a number!!)
If there was a way to limit the input somehow I'd be very grateful.
basically it's an app that tests if the number I inserted is even or odd. The coding in GML goes as follows:
Code:
var number = get_integer("Type a Number.",0);
if( is_real(number)== true){
if(number%2 ==0){
show_message("The number "+string(number)+" is even.");
}
else if(number%2==1){
show_message("The number "+string(number)+" is odd.");
}
}
else{
show_message("Insert numbers only.");
}
the exact problem i'm having is that currently, I am able to type a word and since GML considers words as "0", the app gives out the even message when it is clearly not even (it's not even a number!!)
If there was a way to limit the input somehow I'd be very grateful.