Problem with math formula

I am making a simple math game for kids and I have a little problem with division numbers.
As it is a game for kids the result must not have decimals like 7/9=0.77
Is there a way to check if the number will have decimals so I can shuffle the formula again?

Comments

  • TheGabfatherTheGabfather Member Posts: 633
    edited June 2013
    Sure! You can use the modulo operator :) it gives you the "remainder." So just check if it is equal to 0, then it means you get a whole number. Otherwise, shuffle.

    If you look it up, it's the "%" symbol, but for GS try to use mod(x,y).

    % will work but it's not advised.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited June 2013
    Generally the formulas for simple math games work like this--

    Make three integer attributes: num1, num2, answer

    Addition:
    num1 = random(0,9)
    num2 = random(0,9)
    answer = num1 + num2

    Multiplication:
    num1 = random(0,9)
    num2 = random(0,9)
    answer = num1 * num2

    Subtraction:
    answer = random(0,9)
    num2 = random(0,9)
    num1 = answer + num2

    Division:
    answer = random(0,9)
    num2 = random(0,9)
    num1 = answer * num2
  • TheGabfatherTheGabfather Member Posts: 633
    edited June 2013
    @RThurman To MATH be the glory! 8->

    I've never looked at division that way. And to think you called it basic.

    Time to implement and cash-in! $-)

    edit: @Tokuhara make sure to use this. It will make things a whole lot simpler for your game :)
  • TokuharaTokuhara Member Posts: 94
    What I am doing is like this:
    9 (?) 9 = 81
    And you have to choose the symbols (+), (-), (x) and (/)
    I will try it
    Thanks guys!
  • ADSentertainmentADSentertainment Member Posts: 397
    Sure! You can use the modulo operator :) it gives you the "remainder." So just check if it is equal to 0, then it means you get a whole number. Otherwise, shuffle.

    If you look it up, it's the "%" symbol, but for GS try to use mod(x,y).

    % will work but it's not advised.
    What's wrong with using the % symbol?

    Having trouble with your game? Sounds like a personal problem.

Sign In or Register to comment.