rs =require("readline-sync");
let island = false;
let name1 = "1";
let mima1 = "2";
let money=20000;
let acount=10000;
const MAX_ACOUNT=100000;
for(let i=1;i<=3;i++){
console.log("请输入用户名");
let name2 = rs.question();
console.log("请输入密码");
let mima2 = rs.question();
if(name1==name2&&mima1==mima2){
island = true;
break;
}
else{
console.log("你的账号或密码错误,你今天登陆次数还剩"+(3-i));
}
if(i>3){
console.log("本日次数已达上限,请联系银行人员");
break;
}
}
while(island){
console.log("请输入你要服务的项目:1.查询 2.取钱 3.存钱 4.其他 5.退出 6.改密");
let num=rs.question() -0;
switch(num){
case 1:console.log("你的余额为"+money);
break;
case 2:console.log("请输入你的取款金额");let quqian=rs.question() -0;
if(quqian>money||quqian%100!=0){
console.log("你输入的金额不正确,请重新输入");
}
else if(quqian>5000){
console.log("单次取款金额为5000,请确认取款金额");
}else if(quqian>=acount){
console.log("机器故障,请联系工作人员");
}
else{
money-=quqian;
acount-=quqian;
console.log("取钱成功,当前卡上余额为"+money);
}
break;
case 3:console.log("请将你的现金整齐放入入钞口,并按确认键");
let cunqian=rs.question() -0;
if(cunqian%100!=0){
console.log("你放入的钞票内有不能识别的钞票,请确认后再放");
}else if(cunqian+acount>MAX_ACOUNT){
console.log("机器故障,请联系工作人员");
}
else{
money+=cunqian;
acount+=cunqian;
console.log("存款成功,当前卡上余额为:"+money);
}
break;
case 4:console.log("这项服务已暂停");
break;
case 5:
island=false;
break;
case 6:console.log("请输入你的新密码");
let xinmima1=rs.question() -0;
console.log("请在此输入你的新密码");
if(mima2=xinmima2){
console.log("你两次输入密码不一样");
break;
}
mima1=xinmima1
console.log("你的密码修改成功,新密码为"+mima1);
break;
default:console.log("你输入的不正确");
break;
}
}
console.log("请收好你的卡片,欢迎下次光临");