用ASP程序实现计算器功能(请各位帮帮忙)
可根据用户输入的操作数和所想做的加、减、乘、除运算计算出结果,并在同一页的下方将用户所进行的算式及结果显示出来(要求表单用POST方法递交)。
要求显示的页面如下:
操作数1:(方框内可填入小数)
操作数2:(方框内可填入小数)
选择需要要进行的运算
O 加
O 减
O 乘
O 除
开始运算(按钮) 重置(按钮)
--------------------------------
显示运算式及结果(例如:1+2=3)
参考答案:<html>
<title>
计算器
</title>
<body>
<form action=untitled1.asp method=post>
操作数1: <input type=text name=num1><br>
操作数2: <input type=text name=num2><br>
<p>
选择你要进行的操作<br>
<input type=radio name=operation value="加" checked>加<br>
<input type=radio name=operation value="减">减<br>
<input type=radio name=operation value="乘">乘<br>
<input type=radio name=operation value="除">除<br>
<input type=submit><input type=reset>
</form>
<hr>
<%
dim n1,n2,op
if request.form.count=0 then
response.end
end if
n1=request.form("num1")
n2=request.form("num2")
op=request.form("operation")
if op="加" then
response.write n1
response.write "+"
response.write n2
response.write "="
response.write clng(n1)+clng(n2)
elseif op="减" then
response.write n1
response.write "-"
response.write n2
response.write "="
response.write clng(n1)-clng(n2)
elseif op="乘" then
response.write n1
response.write "*"
response.write n2
response.write "="
response.write clng(n1)*clng(n2)
elseif op="除" then
response.write n1
response.write "/"
response.write n2
response.write "="
response.write clng(n1)/clng(n2)
end if
%>