143、计算存贮器

143、计算存贮器

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT language="JavaScript">

<!--

 

function random (maxValue)

 

{

day= new Date();

hour= day.getHours();

min=day.getMinutes();

sec=day.getSeconds();

mili=day.getTime()

return(((hour*3600)+(min*60)+(sec)+mili) % maxValue);

}

function ranom (maxValue)

//Calculates another random number

{

day= new Date();

mil=day.getTime();

return((mil) % maxValue);

}

 

//--

function add()

//function for addition

{

//If radiobutton 0 =checked then level, radiobutton 1-->level 2, else level 3

if(document.rekenen.arithmetic[0].checked)

maxValue=10

else

{if(document.rekenen.arithmetic[1].checked)

maxValue=30

else{

maxValue=60}}

//random numbers selected

numA=random(maxValue)

numB=ranom(maxValue)

 

numC=numA + numB

Answer=window.prompt(  numA + "+"  + numB +  " = ", 0);

if(window.confirm("你想看一下你回答的是否正确吗? " +numA+  " + " +numB ))

ans()

else{

alert("请过一会重新试一下!")

}

}

 

//--

function subtract()

//If radiobutton 0 =checked then level, radiobutton 1-->level 2, else level 3

{

if(document.rekenen.arithmetic[0].checked)

maxValue=10

else

{if(document.rekenen.arithmetic[1].checked)

maxValue=30

else{

maxValue=60}}

//random numbers selected

numA=random(maxValue)

numB=ranom(maxValue)

numC=numA - numB

Answer=window.prompt(  numA + "-"  + numB+  " = ", 0);

if(window.confirm("你想看一下你回答的是否正确吗?" +numA+  " - " +numB ))

ans()

else{

alert("请过一会重新试一下!")

}

}

 

 

 

//--

function devide()

//If radiobutton 0 =checked then level, radiobutton 1-->level 2, else level 3

{

if(document.rekenen.arithmetic[0].checked)

maxValue=10

else

{if(document.rekenen.arithmetic[1].checked)

maxValue=30

else{

maxValue=60}}

alert("请按四舍五入原则计算!")

//random numbers selected

numA=random(maxValue)+1;

numB=ranom(maxValue)+1;

numC=numA / numB;

numC=Math.round(numC)

Answer=window.prompt(  numA + "/"  + numB +  " = ", 0);

if(window.confirm("你想看一下你回答的是否正确吗? " +numA+  " / " +numB ))

ans()

else{

alert("请过一会重新试一下!")

}

}

 

 

//----

function multiply()

//If radiobutton 0 =checked then level, radiobutton 1-->level 2, else level 3

{

if(document.rekenen.arithmetic[0].checked)

maxValue=10

else

{if(document.rekenen.arithmetic[1].checked)

maxValue=30

else{

maxValue=60}}

//random numbers selected

numA=random(maxValue)

numB=ranom(maxValue)

numC=numA * numB

Answer=window.prompt(  numA + "*"  + numB +  " = ", 0);

if(window.confirm("你想看一下你回答的是否正确吗? " +numA+  " * " +numB ))

ans()

else{

alert("请过一会重新试一下!")

}

}

function score()

{

correct=0

wrong=0

}

function check()

{

alert("你的成绩\n "

+" : " +correct+ " 个答对了\n"

+"  : " +wrong+  " 个答错了 ")

}

//---

function ans()

{

 

if (Answer == numC)

{correct==correct++

alert("恭喜你,你回答对了.")}

else

 

{wrong==wrong++

alert("你的回答:  " +Answer+ "  是错误的."

+ " 正确的答案是:"

+ " = " +numC)}

}

//-->

</Script>

<font>

<Form Name="rekenen">

<INPUT type="button" value="加法" onClick="add()">

<INPUT type="button" value="减法" onClick="subtract()">

<INPUT type="button" value="乘法" onClick="multiply()">

<INPUT type="button" value="除法" onClick="devide()"><br>

<INPUT type="radio" name="arithmetic" >普通水平

<INPUT type="radio" name="arithmetic" checked>中等水平

<INPUT type="radio" name="arithmetic" >高级水平<br><p>

<INPUT type="button" value="查看成绩" onClick="check()">

<INPUT type="button" value="重新开始" onClick="score()">

</form></font>

 

 

 

第二步:把<body>区域中的内容为

<body bgColor=#fef4d9 onLoad="score()">

 

Write a comment

Comments: 0