1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| 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': alert('正在退出...') break; } }
|