JavaScript初学者案例------循环------简易ATM机
程序员文章站
2022-06-28 18:13:30
JavaScript初学者案例------循环实现简易ATM机 Document
JavaScript初学者案例------循环实现简易ATM机
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var money = 100;
var price = 0;
while(num != 4) {
var num=prompt("请输入你要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出");
switch(num) {
case '1':
price = prompt("输入要存的钱数:");
money = money + parseFloat(price);
alert("您的剩余余额:" + money);
continue;
case '2':
price = prompt("输入要取的钱数:");
money = money - parseFloat(price);
alert("您的剩余余额:" + money);
continue;
case '3':
alert("您的剩余余额:" + money);
continue;
case '4':
break;
}
}
alert("成功退出!");
</script>
</head>
<body>
</body>
</html>
本文地址:https://blog.csdn.net/qq_45224140/article/details/109257672