rs2002
March 28th, 2002, 06:38 PM
i have a multiplication of 2 numbers and an input box so that the user can write the answer;the code for the numbers is:
on (release) {
        var c=random(1000)*0.1 //first number: <1000 which i want with one decimal
        var d=random(100) //second number which i want <100
        var e = ""; // name of the input box where the user writes the answer
        var res = c*d; //the result
        trace(res);
}
Now i have a button that displays whether the answer is correct or not; the code is:
on (release) {
        var certo; // dynamic text box variable which says whether the answer is correct or not
        if (res != e) {
        certo = "wrong...";
        }
        else {certo = "right!";
        }
}
I trace the result so i can easily compare results; but for some strange reason, one time and another the answer says diferent things from the true result, or, on another words, says wrong when should say right, like:
97.3x4=389.2
says its a wrong answer.
Where is the mistake?
Can anyone help?
on (release) {
        var c=random(1000)*0.1 //first number: <1000 which i want with one decimal
        var d=random(100) //second number which i want <100
        var e = ""; // name of the input box where the user writes the answer
        var res = c*d; //the result
        trace(res);
}
Now i have a button that displays whether the answer is correct or not; the code is:
on (release) {
        var certo; // dynamic text box variable which says whether the answer is correct or not
        if (res != e) {
        certo = "wrong...";
        }
        else {certo = "right!";
        }
}
I trace the result so i can easily compare results; but for some strange reason, one time and another the answer says diferent things from the true result, or, on another words, says wrong when should say right, like:
97.3x4=389.2
says its a wrong answer.
Where is the mistake?
Can anyone help?