简易ATM
作者:互联网
新手出道 有很多东西都还不太了解,做的也不是很好,但是可以实现简单的ATM操作!
var shuru = prompt('请输入操作 \n1.存钱\n2.取钱\n3.显示余额\n4.退出'); var money = 100; while (true) { if (shuru == '1') { var cunqian = prompt('请输入存的钱数:'); cunqian = parseInt(cunqian); money = money + cunqian; // money += cunqian alert('余额为' + money + '元'); shuru = prompt("请输入操作:\n 1.存钱\n2.取钱\n3.显示余额\n4.退出"); } else if (shuru == '2') { var quqian = prompt('请输入要取的钱数:') quqian = parseInt(quqian); money = money - quqian; alert('余额为' + money + '元'); shuru = prompt("请输入操作:\n 1.存钱\n2.取钱\n3.显示余额\n4.退出"); } else if (shuru == '3') { alert('余额为' + money + '元'); shuru = prompt("请输入操作:\n 1.存钱\n2.取钱\n3.显示余额\n4.退出"); } else if (shuru == '4') { alert('您已成功退出!') break; } else { alert('请输入正确的内容'); shuru = prompt("请输入操作:\n 1.存钱\n2.取钱\n3.显示余额\n4.退出"); } }标签:prompt,money,ATM,alert,shuru,简易,n2,cunqian 来源: https://www.cnblogs.com/HsAndMd/p/16364565.html