//1.基础版atm机(给出帐号密码,判断操作)
const readline = require('readline-sync');
console.log('请输入帐号');
let na = readline.question();
console.log('请输入密码');
let pwd = readline.question();
let name = 'lili'; passworld = 123; money = 1000;
let i = true;
if (na == name && pwd == passworld) {
console.log(`${na}登录成功,余额为${money}`)
while (i) {
console.log(`请选择操作:1:存钱,2:取钱,3:查询余额,4:退出:`);
let count = readline.question() - 0;
switch (count) {
case 1:
console.log('请输入存钱金额:');
let jin = readline.question() - 0;
money+=jin;
console.log(`存钱成功,余额为:${money}`);
break;
case 2:
console.log('请输入取钱金额:');
let save = readline.question() - 0;
if (save <= money) {
money -= save;
console.log(`取钱成功,余额为:${money}`);
} else {
console.log(`余额不足`);
}
break;
case 3:
console.log('查询余额:');
console.log(`余额为:${money}`);
break;
case 4:
i=false;
console.log("欢迎下次光临");
break;
}
}
} else {
console.log('帐号或密码输入错误,请重新输入');
}