当前位置:网站首页>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);
边栏推荐
- Mysql interactive_ Timeout and wait_ Timeout differences
- Compatible with Internet Explorer
- Matlab notes
- Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
- Database query optimization method
- 电脑的dwg文件怎么打开
- Customize the console plot result style
- 多睡觉,能减肥,芝加哥大学最新研究:每天多睡1小时,等于少吃一根炸鸡腿...
- Eyeshot 2022 Released
- ASEMI大功率场效应管和三极管的区别
猜你喜欢

Vscade setting clang format
![[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]](/img/a1/f7a35a04e180e89d7f2fdbf89c1160.jpg)
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]

Web3 DApp用户体验最佳实践

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

win11蓝牙无法连接怎么办?win11蓝牙无法连接的解决方法

Qdebug June 2022

Route parameters to jump to the page and transfer parameters -- > hidden parameter list

Eyeshot Ultimate 2022 Crack By Xacker

Web3 DAPP user experience best practices

Summary of SQL injection (I)
随机推荐
Region of Halcon: generation of multiple regions (3)
At the age of 30, I began to learn programming by myself. Is it still time for me to have difficulties at home?
OOP stack class template (template +ds)
Abuse unlimited authorization -- is your address safe?
Kotlin compose perfect todo project surface rendering background and shadow
Which programming language is the most cumbersome to implement Hello world?
Database overview
【Keil】ADuCM4050官方库的GPIO输出宏定义
Penetration information collection steps (simplified version)
Why is the TCP handshake just 3 times?
My IC journey - the growth of senior chip design verification engineers - "Hu" said that IC engineers are perfect and advanced
How do the defi protocols perform under this round of stress test?
【FLink】access closed classloader classloader. check-leaked-classloader
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
Why PHP is not safe
Laravel Aurora push
Rce code execution & command execution (V)
绝了!自动点赞,我用 PyAutoGUI!
The print area becomes smaller after epplus copies the template
Two hours to take you into the software testing industry (with a full set of software testing learning routes)