PDA

View Full Version : My Math Tutor



razorbladekiss
03-17-2008, 05:23 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Semi-Semester Project - Math Tutor</title>
<style type="text/css">
h2
{
color: #0000FF;
font-family: Arial, Helvetica, sans-serif;
}
h3
{
color: #0000FF;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<!--


Description...: Student chooses a level, a problem type operator, and then clicks "Start".

Ten (10) random problems will be generated for the appropriate level and operator.

Student should answer the generated problem, click "Check Answer" (error message is displayed in the status bar for an incorrect answer), and then click "Next problem".

Student will get three chances to answer the problem. If the student can't answer in three chances, display a message showing the correct answer and tell them to click "Next problem".

Error Messages are selected at random:
No Please try again.
Wrong. Try once more.
Don�t give up!
No. Keep trying

Script will keep a count of the number of correct answers on the first try. After the 10 problems are done, a message is displayed showing the percent correct along with the following message:
If percentage < 70 - �Ask your teacher for help�
If percentage >= 70 - "Select new operation and press 'Start' to work on more problems"

-->

<script type="text/javascript">

var strOperator = "";
var intProbCntr;
var intOp1 = 0;
var intOp2 = 0;
var intProbAns = 0;

//Function to get form elements
function getElementsType()
{
var blnRadio = false;
var prbTypeValue = "";

intProbCntr = 0;

// Validate if radio button is checked
for(i=0; i<document.MathTutor.prbType.length; i++)
{
if (document.MathTutor.prbType[i].checked)
{
blnRadio = true;
}
}

if(blnRadio)
{
if(document.MathTutor.prbType[0].checked)
{
prbTypeValue = document.MathTutor.prbType[0].value;
strOperator = "+";
}
if (document.MathTutor.prbType[1].checked)
{
prbTypeValue = document.MathTutor.prbType[1].value;
strOperator = "-";
}
if (document.MathTutor.prbType[2].checked)
{
prbTypeValue = document.MathTutor.prbType[2].value;
strOperator = "*";
}
if (document.MathTutor.prbType[3].checked)
{
prbTypeValue = document.MathTutor.prbType[3].value;
strOperator = "/";
}

//Call Random Problems Function
getRandomNums();

}
else
{
alert("Must select a Problem Type. Please try again.");
return;
}
}


//Function to get random problems
function getRandomNums()
{
if (intProbCntr<=9)
{
switch(document.MathTutor.gradeLevel.value)
{
case "lvl1":
intOp1 = Math.floor(Math.random() * 11);
intOp2 = Math.floor(Math.random() * 11);
break;
case "lvl2":
intOp1 = Math.floor(Math.random() * 101);
intOp2 = Math.floor(Math.random() * 101);
break;
}

/*
Check random numbers during:
subtraction and first random number less than second random number
division has remainder
division and first random number equals zero or second random number equals zero
then call function to get random problem again before displaying
*/
if ( (strOperator == "-" && intOp1<intOp2) ||
(intOp1%intOp2) ||
(strOperator == "/" && intOp1 == 0 || intOp2 == 0) )
{
getRandomNums();
}
else
{
document.MathTutor.txtProblem.value = intOp1 + " " + strOperator + " " + intOp2 + " =";
intProbCntr++;
}
}
}

//Function to get problem answer
function getAnswer()
{
switch(strOperator)
{
case "+":
intProbAns = intOp1 + intOp2;
break;
case "-":
intProbAns = intOp1 - intOp2;
break;
case "*":
intProbAns = intOp1 * intOp2;
break;
case "/":
intProbAns = intOp1 / intOp2;
break;

}

/* var randomErrorMsg = new Array ();
randomErrorMsg[0] = "No Please try again.";
randomErrorMsg[1] = "Wrong. Try once more.";
randomErrorMsg[2] = "Don't give up!";
randomErrorMsg[3] = "No. Keep trying.";*/

if (parseInt(document.MathTutor.txtAnswer.value) = 0){
alert("Correct");
else
alert("Incorrect");
}



</script>

<noscript>
<h1>Unable to process with JavaScript turned off</h1>
</noscript>

</head>

<body bgcolor="#FFFFCC">

<!-- Page Title -->
<h2 align="center">Math Tutor</h2>

<form id="MathTutor" name="MathTutor">
<p><hr color="gray"></p>

<!-- List Box - Grade Level -->
<p><h3>Choose Grade Level</h3>
<select name="gradeLevel" id="gradeLevel">
<option name="grdLevel1" id="grdLevel1" value="lvl1">Level 1</option>
<option name="grdLevel2" id="grdLevel2" value="lvl2">Level 2</option>
</select>
</p>

<!-- Radio Button - Operator -->
<p><h3>Choose Problem Type</h3>
<input type="radio" name="prbType" id="add" value="add"> Addition<br />
<input type="radio" name="prbType" id="sub" value="sub"> Subtraction<br />
<input type="radio" name="prbType" id="mult" value="mult"> Multiplication<br />
<input type="radio" name="prbType" id="div" value="div"> Division<br /><br />
<button name="btnProbType" onclick="getElementsType()">Start</button>
</p>

<p><hr color="gray"></p>

<!-- Area to display ten (10) random math problems based on operator -->
<p><h3>Problem</h3>
<input type="text" name="txtProblem" size="5" value="" readonly="readonly">&nbsp&nbsp&nbsp <input type="text" name="txtAnswer" size="5">&nbsp&nbsp&nbsp

<!-- Button to check problem answer -->
<button name="btnCkAns" onclick="getAnswer()">Check Answer</button>
</p>

<!-- Button to request next random problem -->
<button name="btnNxtProb" onclick="getRandomNums()">Next problem</button>

</form>

</body>
</html>

The portions I'm stuck on are:

Student should answer the generated problem, click "Check Answer" (error message is displayed in the status bar for an incorrect answer), and then click "Next problem".

Student will get three chances to answer the problem. If the student can't answer in three chances, display a message showing the correct answer and tell them to click "Next problem".

Error Messages are selected at random:
No Please try again.
Wrong. Try once more.
Don�t give up!
No. Keep trying

Script will keep a count of the number of correct answers on the first try. After the 10 problems are done, a message is displayed showing the percent correct along with the following message:
If percentage < 70 - �Ask your teacher for help�
If percentage >= 70 - "Select new operation and press

any help would be greatly appreciated...thank you!

boogyman
03-17-2008, 06:29 PM
we arent here to do your homework...
if you have a specific question on something we can explain the method behind it, but unless you do the assignment you wont be learning the material