计算器.html
标签:第一个 return prompt cti func oat turn UNC else
<script type=”text/javascript”>
var num1=window.prompt(‘请输入第一个数‘);
var num2=window.prompt(‘请输入第二个数‘);
var operator=window.prompt(‘请输入运算符‘);
num1=parseFloat(num1);
num2=parseFloat(num2);
//调用函数
document.writeln(num1+operator+num2);
document.writeln(“结果=”+jiSuan(num1,num2,operator));
function jiSuan(num1,num2,operator)
{
var res=0;
if (operator==”+”)
{
res=num1+num2
}else if (operator==”-“)
{
res=num1-num2
}else if (operator==”*”)
{
res=num1*num2
}else if (operator==”/”)
{
res=num1/num2
}else if (operator==‘%‘)
{
res=num1/num2
}
return res;
}
</script>
计算器.html
标签:第一个 return prompt cti func oat turn UNC else
原文地址:https://www.cnblogs.com/d534/p/12868264.html