<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>四则运算</title>
</head>
<body>
<input type="button" value="计算两数运算结果" onclick="count()"/>
<script type="text/javascript">
function count(){
/*var num1 = prompt("请输入第一个数:");
var num2 = prompt("请输入第二个数:");*/
var n1 = parseInt(prompt("请输入第一个数:"));
var n2 = parseInt(prompt("请输入第二个数:"));
var op = prompt("请输入运算方式:");
var result;
switch (op){
case "+":
result=n1+n2;
break;
case "-":
result=n1-n2;
break;
case "*":
result=n1*n2;
break;
case "/":
result=n1/n2;
break;
}
alert("两数运算结果为:"+n1+op+n2+"="+result);
}
</script>
</body>
</html>
04-02
1015
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)