Author |
Message |
upandatom
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Sun Jan 16, 2005 8:47 pm Post subject: (No subject) |
|
|
by using the Rand module in turing and some ingenuity. |
|
|
|
|
![](images/spacer.gif) |
susan_101
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
susan_101
|
Posted: Sun Jan 16, 2005 8:56 pm Post subject: (No subject) |
|
|
lol cervantes you again, im glad you are on this thingy ![Laughing Laughing](http://compsci.ca/v3/images/smiles/icon_lol.gif) |
|
|
|
|
![](images/spacer.gif) |
susan_101
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
TheXploder
![](http://www22.brinkster.com/thexploder/chess.jpg)
|
Posted: 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
|
|
|
|
|
|
![](images/spacer.gif) |
Neo
![](http://compsci.ca/v3/uploads/user_avatars/441131374462fea7633fd3.gif)
|
Posted: 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 |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
susan_101
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
susan_101
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
susan_101
|
Posted: Sun Jan 16, 2005 10:15 pm Post subject: (No subject) |
|
|
anyone? aww im being ignored lol |
|
|
|
|
![](images/spacer.gif) |
Bacchus
![](http://img104.exs.cx/img104/9206/ravenmoon12ns.jpg)
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
|