当前位置:网站首页>JS function to realize simple calculator
JS function to realize simple calculator
2022-06-25 05:02:00 【Dai Sensen】

var n = prompt(' Welcome to the easy calculator :\n1. Addition calculator :\n2. Subtraction calculator :\n3. Multiplication calculator :\n4 Division calculator :\n5. sign out :\n Please enter your choice :');
function Calculate(n) {
n = parseInt(n);
while (n != 5) {
switch (n) {
case 1:
n1 = parseInt(prompt(' Please enter the first number '));
n2 = parseInt(prompt(' Please enter the second number '));
alert(n1 + n2);
break;
case 2:
n1 = parseInt(prompt(' Please enter the first number '));
n2 = parseInt(prompt(' Please enter the second number '));
alert(n1 - n2);
break;
case 3:
n1 = parseInt(prompt(' Please enter the first number '));
n2 = parseInt(prompt(' Please enter the second number '));
alert(n1 * n2);
break;
case 4:
n1 = parseInt(prompt(' Please enter the first number '));
n2 = parseInt(prompt(' Please enter the second number '));
alert(n1 / n2);
break;
case 5:
n = 5;
break;
}
n = prompt(' Welcome to the easy calculator :\n1. Addition calculator :\n2. Subtraction calculator :\n3. Multiplication calculator :\n4 Division calculator :\n5. sign out :\n Please enter your choice :');
n = parseInt(n);
}
}
Calculate(n);
边栏推荐
- Notes on non replacement elements in the line (padding, margin, and border)
- How PHP gets the user's City
- Kotlin compose perfect todo project surface rendering background and shadow
- Method of opening data recovery of solid state disk
- MySQL concept and operation (III)
- ORA-00800: soft external error
- Fun CMD command line~
- Database overview
- Penetration test - directory traversal vulnerability
- Apache+php uploading large files
猜你喜欢

dotnet-exec 0.4.0 released

Why does the SQL statement hit the index faster than it does not?

Vscade setting clang format

What is Ethernet and how to connect the computer

WPF 使用 MAUI 的自绘制逻辑

Records of ros2/dds/qos/ topics

PHP calls map API

What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect

Kotlin Compose 监听软键盘 点击enter提交事件

How do the defi protocols perform under this round of stress test?
随机推荐
Huawei Hongmeng development lesson 4
OpenSea PHP开发包
2021-10-24
渗透测试-目录遍历漏洞
dotnet-exec 0.4.0 released
ASEMI三相整流桥的工作原理
WPF 使用 MAUI 的自绘制逻辑
【Flink】RocksDB增量模式checkpoint大小持续增长的问题及解决
Introduction to the hardest core PWN in the whole network_ Graphic analysis
In Net 6 using dotnet format formatting code
执行SQL响应比较慢,你有哪些排查思路?
OLAP analysis engine kylin4.0
Difference between asemi high power FET and triode
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
PHP calls map API
Swift rapid development
Detailed summary of position positioning
How to install the blue lake plug-in to support Photoshop CC 2017
电脑的dwg文件怎么打开
Customize the console plot result style