Click to See Complete Forum and Search --> : Help Plz....emergency
Nikki
03-25-2003, 03:24 PM
I need help with writing a srcipt using Math.random to produce 2 one-digit intergers to help elementary students do math.
The program should display a question such as "How much is 6 times 7?"
If the student answers correctly, then display string "Very good!" if not then diplay "No. Please try again."
THANK YOU SO MUCH.
Did you need help with a certain part of the script?
AdamGundry
03-25-2003, 03:32 PM
Try something like this. You can use <body onLoad="Ask()"> to start this off.
<script type="text/javascript">
function Ask(){
var n1 = Math.int(Math.random()*8)+1;
var n2 = Math.int(Math.random()*8)+1;
var a = 0;
a = prompt("What is " + n1 + " times " + n2 + "?", "");
if (parseInt(a) == n1*n2){
alert("Very good!");
} else {
alert("No, please try again!");
setTimeout("Ask()",1);
}
}
</script>
You might want to modify this script to use form elements, rather than popup boxes. Also, if they get a question wrong they get a different question, rather than the same again - this could be changed.
Hope this helps
Adam
Nikki
03-25-2003, 03:37 PM
I just started this JavaScript class. Well, I'm not a programmer so I think I need help with the whole thing. This is my project & the professor didn't even explain or teach us what to do. Just gave the problem. I really don't know how to write it.
The question asked:
Write a program that will help an elementary student learn mutiplication. Use Math.random to produce two positive 1-digit integers. It should then display a question such as
"How much is 6 times 7?"
The student then types the answer into a text field. Your program checks the student's answers. If it's correct, display string "Very good!" if not display "No. Please try again." in the browser's status bar. Each question should only be asked once.
nkaisare
03-25-2003, 03:58 PM
Does this amount to cheating? :rolleyes:
Nikki
03-25-2003, 04:10 PM
Not cheating, helping. If he explained & taught us what he supposed to, the it would be cheating but since we just started & have to write a program like this, I don't think it's cheating.