<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script>
var num1=prompt("请输入一个数:");
var fu=prompt("请输入运算符");
var num2=prompt("请再输入一个数:");
switch(fu){
case "+":
alert(num1+"加上"+num2+"="+(parseFloat(num1)+parseFloat(num2)));
break;
case "-":
alert(num1+"减去"+num2+"="+(parseFloat(num1)-parseFloat(num2)));
break;
case "*":
alert(num1+"乘以"+num2+"="+parseFloat(num1)*parseFloat(num2));
break;
case "/":
alert(num1+"除以"+num2+"="+parseFloat(num1)/parseFloat(num2));
break;
default:
alert("你的操作有误!");
break;
}
</script>
</html>
打开App,阅读手记