***测试搜索***加减乘除的运算测试
把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件要完成此效果需要两个步骤
第一步:把如下代码加入到<head>区域中
<script language="javascript">
<!-- begin
correct=0;
wrong=0;
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) {
day= new date();
mil=day.gettime();
return((mil) % maxvalue);
}
function add() {
if(document.quizform.arithmetic.checked)
maxvalue=10;
else {
if(document.quizform.arithmetic.checked)
maxvalue=30;
else {
maxvalue=60;
}
}
numa=random(maxvalue);
numb=ranom(maxvalue);
numc=numa + numb;
answer=window.prompt(numa + "+"+ numb +" = ", "");
ans();
}
function subtract() {
if(document.quizform.arithmetic.checked)
maxvalue=10;
else
{if(document.quizform.arithmetic.checked)
maxvalue=30;
else {
maxvalue=60
}
}
numa=random(maxvalue);
numb=ranom(maxvalue);
numc=numa - numb;
answer=window.prompt(numa + "-"+ numb+" = ", 0);
ans()
}
function divide() {
if(document.quizform.arithmetic.checked)
maxvalue=10;
else {
if(document.quizform.arithmetic.checked)
maxvalue=30;
else {
maxvalue=60
}
}
numa=random(maxvalue)+1;
numb=ranom(maxvalue)+1;
numc=numa / numb;
numc=math.round(numc)
window.alert("please round your answer off:\n"
+".5 or higher rounds one number up\n"
+".4 or lower rounds one number down");
answer=window.prompt(numa + "/"+ numb +" = ", 0);
ans()
}
function multiply() {
if(document.quizform.arithmetic.checked)
maxvalue=10;
else {
if(document.quizform.arithmetic.checked)
maxvalue=30;
else {
maxvalue=60
}
}
numa=random(maxvalue);
numb=ranom(maxvalue);
numc=numa * numb;
answer=window.prompt(numa + "*"+ numb +" = ", 0);
ans();
}
function check() {
if ((correct+wrong) != 0) {
score = "" + ((correct / (correct + wrong)) * 100);
score = score.substring(0,4) + "%";
alert("你的答题正确率是:" + score + "\n"
+ correct + " 次答对\n"
+ wrong + " 次答错")
}
else alert("你还未完成任一习题.");
}
function ans() {
if (answer == numc) {
correct++;
msg = "恭喜, 你回答正确.";
}
else {
wrong++;
msg = "回答错误!" + answer + " 这个答案不对.\n\n"
+ "正确答案应该是 " +numc + ".";
}
score = "" + ((correct / (correct + wrong)) * 100);
score = score.substring(0,4) + "%";
alert(msg + "\n\n你的正确率:" + score + "\n"
+ correct + " 次答对\n"
+ wrong + " 次答错")
}
//end -->
</script>
第二步:把如下代码加入到<body>区域中
<center>
<form name=quizform>
<input type=button value="加法运算" onclick="add()">
<input type=button value="减法运算" onclick="subtract()">
<input type=button value="乘法运算" onclick="multiply()">
<input type=button value="除法运算" onclick="divide()">
<br>
<br>
<input type="radio" name="arithmetic">
低级难度
<input type="radio" name="arithmetic" checked>
中等难度
<input type="radio" name="arithmetic">
高级难度 <br>
<br>
<input type=button value="显示计分" onclick="check()">
<input type=button value="重新计分" onclick="javascript:correct=0;wrong=0;">
</form>
</center>
--------------------------------------
http://www.huoyue.com.cn 活跃网,活跃人群的论坛,访问活跃网,将给您带来意想不到的收获,还可以免费为您开论坛,让您免费拥有与朋友、网友交流的论坛。你是年轻人吗?你活跃你就上!
页:
[1]