<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var num0 = 100;
while (true) {
var num = prompt('请输入您要的操作:\n1.存钱\n2.取钱\n3.显示余额\n4.退出');
num = parseInt(num);
switch (num) {
case 1:
var cun = prompt('请输入你要存的钱数:');
num0 = num0 + parseInt(cun);
alert('您现在的钱数是:' + num0);
break;
case 2:
var qu = prompt('请输入您要取的钱:');
num0 = num0 - parseInt(qu);
alert('您现在的钱数是:' + num0);
break;
case 3:
alert('您现在的钱数是:' + num0);
break;
case 4:
alert('退出');
break;
default:
alert('您需要输入1~4');
}
if (num == 4) {
break;
}
}
</script>
</head>
<body>
</body>
</html>