短颈乌德:设计一个可供小学生数学运算测试程序

来源:百度文库 编辑:高考问答 时间:2024/04/29 13:53:40
l 界面美观简洁。
l 测试小学生对10以内两个正数加、减、乘法运算的能力。
l 能根据用户输入确定出题数。
l 随机出题,运算数必须是10以内的正整数,运算符可以是+、-、× 。
l 判断解答是否正确,给出评语。
l 正确的答案可采用如下评语(每次随机选取一个):
n Very good!
n Excellent!
n Keep up the good word!
l 错误的答案可采用如下评语(每次随机选取一个):
n No. Please try again.
n Wrong. Try once more.
n No. Keep trying.
l 如果答案错误允许学生选择重做,在界面上给出提示。
l 累计并显示题数、正确回答次数和错误次数。
l 统计正确率,若正确率低于75%,则打印输出“Please ask your instructor for extra help”。
用C语言编写

将下面代码保存为test.asp,然后在可运行ASP的环境下运行即可。
示范页面:
http://www.hngczy.cn/pgb/zhidaoanswer/xiaoxuecheshiti.asp
==============test.asp==========================
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>小学数学加减乘除</title>
</head>
<body style="font-size:18pt ">
<%
if request.form("action")="ok" then
call ok()
end if
sub ok()
response.write"<font color='blue'>测试结果:(10道题,10分一题)</font><br>"
dim val(11)
dim str(11)
dim i,evl
dim zq,cw
zq=0
cw=0
for i=1 to 10
val(i)=trim(request.form("val"&i))
str(i)=request.form("str"&i)
evl=eval(str(i))
if val(i)="" or (not isnumeric(val(i))) then
response.write str(i)&"= "&val(i)&"(×)<font color='red'>请输入数字</font>。正确答案为:"&eval(str(i))&"<br>"
cw=cw+1
elseif cint(val(i))=evl then
response.write str(i)&"="&val(i)&"(√)<br>"
zq=zq+1
else
response.write str(i)&"="&val(i)&"(×)正确答案为:"&eval(str(i))&"<br>"
cw=cw+1
end if
next
response.write "<input type='button' value=' 返回重做 ' onclick='window.history.back()'> "
response.write "<input type='button' value=' 重新出题 ' onclick=""window.location.href('xiaoxuecheshiti.asp')""><br>"
response.write "正确:"&zq&"个,错误:<font color='red'>"&cw&"</font>个 ,正确率:"&round(zq/10*100,2)&"%,得分:"&zq*10&"分。<br>"
if zq/10<0.75 then
response.write "Please ask your instructor for extra help!"
elseif zq/10>0.9 then
response.write "<font color='blue'>做得不错,继续努力!</font>"
end if
response.end()
end sub
%>
<form action="xiaoxuecheshiti.asp" method="post">
<font color="blue">小学数学加、减、乘法测试题(10道题,10分一题)</font>
<br>
<%
dim a,b
dim z,i
dim temp,res
dim str(11)
i=1
randomize
do while i<11
a=int(rnd()*10)+1
b=int(rnd()*10)+1
temp=int(rnd()*3)+1
select case temp
case 1
z="+"
case 2
z="-"
case 3
z="*"
end select
str(i)=a&z&b
res=eval(str(i))
if res>0 then
response.write a&z&b&"= "&"<input name='val"&i&"' type=text'>"&"<br>"
response.write "<input name='str"&i&"' type='hidden' value="&str(i)&">"
i=i+1
end if
loop
%>
<input name="action" type="hidden" value="ok">
<input name="button" type="submit" value="我做完了,交卷">
<input name="button" type="button" value="重新出题" onclick="window.location.reload()">
</form>
</body>
</html>
=================================================
花了我一个小时,累啊!兄弟记得加分啊!:)