-
Notifications
You must be signed in to change notification settings - Fork 0
/
35-ATM.html
43 lines (40 loc) · 1.06 KB
/
35-ATM.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let balance = 100
let loop = true
while (loop) {
let choice = +prompt(`请输入数字选择
1. 存钱
2. 取钱
3. 查看余额
4.退出`)
switch (choice) {
case 1:
let num = +prompt("请输入金额")
balance += num
break
case 2:
let qu = +prompt("请输入金额")
if (qu >= balance) {
alert("取的钱太多啦")
} else {
balance -= qu
}
break
case 3:
alert(`余额还有${balance}元`)
break
case 4:
loop = false
}
}
</script>
</body>
</html>