Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to make a random math question generator?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
upandatom




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Sun Jan 16, 2005 8:47 pm   Post subject: (No subject)

by using the Rand module in turing and some ingenuity.
susan_101




PostPosted: Sun Jan 16, 2005 8:49 pm   Post subject: (No 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?
Cervantes




PostPosted: Sun Jan 16, 2005 8:52 pm   Post subject: (No 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.
susan_101




PostPosted: Sun Jan 16, 2005 8:56 pm   Post subject: (No subject)

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




PostPosted: Sun Jan 16, 2005 9:03 pm   Post subject: (No 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
TheXploder




PostPosted: Sun Jan 16, 2005 9:39 pm   Post subject: (No 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
Neo




PostPosted: Sun Jan 16, 2005 9:39 pm   Post subject: (No 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
Sponsor
Sponsor
Sponsor
sponsor
susan_101




PostPosted: Sun Jan 16, 2005 9:42 pm   Post subject: (No 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?
susan_101




PostPosted: Sun Jan 16, 2005 9:50 pm   Post subject: (No 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?
susan_101




PostPosted: Sun Jan 16, 2005 10:15 pm   Post subject: (No subject)

Crying or Very sad anyone? aww im being ignored lol
Bacchus




PostPosted: Sun Jan 16, 2005 11:27 pm   Post subject: (No subject)

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




PostPosted: Sun Jan 16, 2005 11:43 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: