<HTML><HEAD><TITLE>Maths Quiz</TITLE><SCRIPT LANGUAGE = JavaScript>var problemCount;var doTen=false; var mistakes=0;var operation;function Operator(message){ var operation; if (message == " ") operation=" "; if (message == "-") operation="-"; if (message == "*") operation="*"; if (message == "/") operation="/"; return (operation);}function newProblem(){ var operation operation = Operator(); document.quiz.firstone.value=4 rollDice(6); document.quiz.operator.value = operation; document.quiz.second.value=rollDice(4); document.quiz.attempt.value="";}function checkAnswer(){ var operation =document.quiz.operator.value; var a = parseInt(document.quiz.firstone.value); /* ensure Javascript knows they are integers*/ var b = parseInt(document.quiz.second.value); var answerA = a b; var answerS = a-b; var answerM = a*b; var answerD = a/b var attempt = document.quiz.attempt.value; if (operation == " ") ok=check(attempt,answerA); if (operation == "-") ok=check(attempt,answerS); if (operation == "*") ok=check(attempt,answerM); if (operation == "/") ok=check(attempt,answerD); if (doTen && ok) { newProblem(); problemCount ; }}function check(attempt,answer){ var ok; if (attempt==answer) { document.quiz.attempt.value = "YES"; ok=true; document.face.src="happy.gif"; } else { document.quiz.attempt.value = "TRY AGAIN"; ok=false; mistakes ; } return(ok);}function rollDice(sides){ var randNumber; var rollValue; randNumber=Math.random(); randNumber=randNumber*sides; randNumber= randNumber 0.5; rollValue=Math.round(randNumber); return(rollValue);}</SCRIPT></HEAD><BODY><CENTER><H2> Maths Quiz </H2></CENTER><BR><FORM NAME = "quiz"><INPUT TYPE="button" VALUE="Addition" onClick="Operator(" ")";><INPUT TYPE="button" VALUE="Subtraction" onClick="Operator("-")";><INPUT TYPE="button" VALUE="Multiplication" onClick="Operator("*")";><INPUT TYPE="button" VALUE="Division" onClick="Operator("/")";><BR><INPUT TYPE="button" VALUE="Get new problem" onClick= "newProblem()";><p><INPUT NAME="firstone" TYPE="text" SIZE=5 ><INPUT NAME="operator" TYPE="text" SIZE=5 ><INPUT NAME="second" TYPE="text" SIZE=5 ><INPUT TYPE = "text" NAME = "attempt" SIZE=9><p> <INPUT NAME="try" TYPE="button" VALUE="Check my answer" onClick= "checkAnswer()"></FORM><CENTER><IMG NAME = face SRC="happy.gif"></BODY> </HTML>
OH MY GOD IT'S JAWS!
<HTML><HEAD><TITLE>Maths Quiz</TITLE><SCRIPT LANGUAGE = JavaScript>var problemCount;var doTen=false; var mistakes=0;var operation;function getOperator(a){ var operation; operation=a; document.quiz.operator.value=operation;}function newProblem(){ var operation operation = document.quiz.operator.value document.quiz.firstone.value=4 rollDice(); document.quiz.operator.value = operation; document.quiz.second.value=rollDice(); document.quiz.attempt.value="";}function checkAnswer(){ var operation =document.quiz.operator.value; var a = parseInt(document.quiz.firstone.value); /* ensure Javascript knows they are integers*/ var b = parseInt(document.quiz.second.value); var answerA = a b; var answerS = a-b; var answerM = a*b; var answerD1 = a/b var answerD2 = Math.round(answerD1*Math.pow(10,2))/Math.pow(10,2); var attempt = document.quiz.attempt.value; if (operation == " ") ok=check(attempt,answerA); if (operation == "-") ok=check(attempt,answerS); if (operation == "*") ok=check(attempt,answerM); if (operation == "/") ok=check(attempt,answerD2); if (doTen && ok) { newProblem(); problemCount ; }}function check(attempt,answer){ var ok; if (attempt==answer) { document.quiz.attempt.value = "YES"; ok=true; } else { document.quiz.attempt.value = "TRY AGAIN"; ok=false; mistakes ; } return(ok);}function rollDice(){ var randNumber; var rollValue; var num1; var num1=document.quiz.message.value if (num1=="You have chosen easy") num1=10; if (num1=="You have chosen normal") num1=50; if (num1=="You have chosen hard") num1=350; randNumber=Math.random(); randNumber=randNumber*num1; randNumber= randNumber 0.5; rollValue=Math.round(randNumber); return(rollValue);}function difficult(message){ if (message==1) document.quiz.message.value="You have chosen easy"; if (message==2) document.quiz.message.value="You have chosen normal"; if (message==3) document.quiz.message.value="You have chosen hard";}</SCRIPT></HEAD><BODY><CENTER><H2> Maths Quiz </H2></CENTER><BR><FORM NAME = "quiz"><INPUT TYPE="button" VALUE="Easy" onClick="difficult('1')"><INPUT TYPE="button" VALUE="Normal" onClick="difficult('2')"><INPUT TYPE="button" VALUe="Hard" onClick="difficult('3')"><BR><INPUT NAME="message" TYPE="text" SIZE=40><BR><INPUT TYPE="button" VALUE="Addition" onClick="getOperator(' ')"><INPUT TYPE="button" VALUE="Subtraction" onClick="getOperator('-')"><INPUT TYPE="button" VALUE="Multiplication" onClick="getOperator('*')"><INPUT TYPE="button" VALUE="Division" onClick="getOperator('/')"><BR><INPUT TYPE="button" VALUE="Get new problem" onClick= "newProblem()";><p><INPUT NAME="firstone" TYPE="text" SIZE=5 ><INPUT NAME="operator" TYPE="text" SIZE=5 ><INPUT NAME="second" TYPE="text" SIZE=5 ><INPUT TYPE = "text" NAME = "attempt" SIZE=9><p> <INPUT NAME="try" TYPE="button" VALUE="Check my answer" onClick= "checkAnswer()"></FORM><CENTER></BODY> </HTML>