
-----------------------------------
upandatom
Sun Jan 16, 2005 8:41 pm

how to make a random math question generator?
-----------------------------------
how to make a random math question generator?

-----------------------------------
AsianSensation
Sun Jan 16, 2005 8:47 pm


-----------------------------------
by using the Rand module in turing and some ingenuity.

-----------------------------------
susan_101
Sun Jan 16, 2005 8:49 pm


-----------------------------------
hmm maybe rand.int(0,999)+rand.int(0,999)? but then how do yu record wat user put down and if its correct?

-----------------------------------
Cervantes
Sun Jan 16, 2005 8:52 pm


-----------------------------------
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.

-----------------------------------
susan_101
Sun Jan 16, 2005 8:56 pm


-----------------------------------
lol cervantes you again, im glad you are on this thingy :lol:

-----------------------------------
susan_101
Sun Jan 16, 2005 9:03 pm


-----------------------------------
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

-----------------------------------
TheXploder
Sun Jan 16, 2005 9:39 pm


-----------------------------------
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...

 
if math_answer=number1+number2 then
  number1 :=Rand.Int(0,99)
  number2 :=Rand.Int(0,99)
end if 


-----------------------------------
Neo
Sun Jan 16, 2005 9:39 pm


-----------------------------------
You generate the random number inside the loop like so:


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

-----------------------------------
susan_101
Sun Jan 16, 2005 9:42 pm


-----------------------------------
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?

-----------------------------------
susan_101
Sun Jan 16, 2005 9:50 pm


-----------------------------------
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?

-----------------------------------
susan_101
Sun Jan 16, 2005 10:15 pm


-----------------------------------
:cry: anyone? aww im being ignored lol

-----------------------------------
Bacchus
Sun Jan 16, 2005 11:27 pm


-----------------------------------
if you want a specific timer then:
from start of program-> Time.Elapsed
from a specific point-> Time.DelaySinceLast

-----------------------------------
[Gandalf]
Sun Jan 16, 2005 11:43 pm


-----------------------------------

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.
