Computer Science Canada

how to make a random math question generator?

Author:  upandatom [ Sun Jan 16, 2005 8:41 pm ]
Post subject:  how to make a random math question generator?

how to make a random math question generator?

Author:  AsianSensation [ Sun Jan 16, 2005 8:47 pm ]
Post subject: 

by using the Rand module in turing and some ingenuity.

Author:  susan_101 [ Sun Jan 16, 2005 8:49 pm ]
Post subject: 

hmm maybe rand.int(0,999)+rand.int(0,999)? but then how do yu record wat user put down and if its correct?

Author:  Cervantes [ Sun Jan 16, 2005 8:52 pm ]
Post subject: 

susan_101 wrote:
hmm maybe rand.int(0,999)+rand.int(0,999)? but then how do yu record wat user put down and if its correct?

Store information as variables.

Author:  susan_101 [ Sun Jan 16, 2005 8:56 pm ]
Post subject: 

lol cervantes you again, im glad you are on this thingy Laughing

Author:  susan_101 [ Sun Jan 16, 2005 9:03 pm ]
Post subject: 

but how would you make it ask different question every time you answer
cervantes?


var number1:real:=Rand.Int(0,99)
var number2:real:=Rand.Int(0,99)
var question:real:=Rand.Int(0,99)
var reply:string
var math_answer:real
loop
put"math question answer?"
get reply
if reply="yes" then

put number1,"+",number2
get math_answer
if math_answer=number1+number2 then
put"you win"
end if
end if
end loop

Author:  TheXploder [ Sun Jan 16, 2005 9:39 pm ]
Post subject: 

ok yeah, first of all you can make it int cause Rand.Int(0,99) will never give a real value thats what Rand.Real does. So something like this to make them random again...

code:

if math_answer=number1+number2 then
  number1 :=Rand.Int(0,99)
  number2 :=Rand.Int(0,99)
end if

Author:  Neo [ Sun Jan 16, 2005 9:39 pm ]
Post subject: 

You generate the random number inside the loop like so:

code:

var number1, number2, answer : int
var reply : string

loop
    put "math question answer?"
    get reply
    if reply = "yes" then
        number1 := Rand.Int (0, 99)
        number2 := Rand.Int (0, 99)
        put number1, "+", number2
        get answer
        if answer = number1 + number2 then
            put "right answer"
        else
            put "wrong answer"
        end if
    end if
end loop

Author:  susan_101 [ Sun Jan 16, 2005 9:42 pm ]
Post subject: 

so guys hwo would yu make a counter in that?
say i wanted to ask as many questions as i wanted within 30 seconds?
anyone know?

Author:  susan_101 [ Sun Jan 16, 2005 9:50 pm ]
Post subject: 

teh counter could be
for decreasing j : 10 .. 1
put j
delay(1000)
cls
end for
but then it erases after and it gets all screwd lol suggestions?

Author:  susan_101 [ Sun Jan 16, 2005 10:15 pm ]
Post subject: 

Crying or Very sad anyone? aww im being ignored lol

Author:  Bacchus [ Sun Jan 16, 2005 11:27 pm ]
Post subject: 

if you want a specific timer then:
from start of program-> Time.Elapsed
from a specific point-> Time.DelaySinceLast

Author:  [Gandalf] [ Sun Jan 16, 2005 11:43 pm ]
Post subject: 

code:

var number1, number2, answer : int
var counter : int := 0
var reply : string

loop
    put "math question answer?"
    get reply
    if reply = "yes" then
        number1 := Rand.Int (0, 99)
        number2 := Rand.Int (0, 99)
        put number1, "+", number2
        get answer
        if answer = number1 + number2 then
            put "right answer"
        else
            put "wrong answer"
        end if
    end if
    counter := counter + 1  %there is a way of doing this like counter += 1 %I think, but I'm not sure.
exit when counter = 30
end loop
put "finished"


Oops, I misread, I thought you said "30 times" not 30 seconds... Oh well, just in case - there you have it.


: