标签:bsp hang ++ put adl console class pre 使用
const readline = require(‘readline-sync‘); let arr = [[‘zhangsan‘,‘123456‘],[‘lisi‘,‘123456‘]]; let menu=‘1.取款\n2.存款\n3.查看\n4.退出‘; let isGister=false; //定义初始登录错误 let inputfalse=0; //定义输入错误次数 while(!isGister) { console.log(‘请输入帐号:‘) let username = readline.question(); console.log(‘请输入密码:‘) let password = readline.question(); for ( i = 0; i < arr.length; i++) { if (username==arr[i][0]&&password==arr[i][1]) { console.log(‘登录成功‘); let flag=true; let balance=0; while(flag) { console.log(menu); console.log(‘请选择:‘) let item = readline.question()-0; switch (item) { case 1: { let flag1=true; while(flag1) { console.log(`当前余额为${balance}元,请输入取款金额:`) let outmoney = readline.question(); balance-=outmoney; console.log(`取款成功,当前余额为${balance}元。`) console.log(‘继续取款请按1,返回上一级就按0‘) let item2 = readline.question()-0; switch (item2) { case 1: break; case 0: flag1=false; } } break;1 } case 2: { let flag1=true; while(flag1) { console.log(`当前余额为${balance}元,请输入存入金额:`) let savemoney = readline.question()-0; balance+=savemoney; console.log(`取款成功,当前余额为${balance}元。`) console.log(‘继续存款请按1,返回上一级就按0‘) let item2 = readline.question()-0; switch (item2) { case 1: break; case 0: flag1=false; } } break; } case 3: { console.log(`当前余额为${balance}元,请输入取款金额:`) console.log(‘返回上一级请按0‘) let item2 = readline.question()-0; switch (item2) { case 1: break; case 0: flag1=false; } break; } case 4: { console.log(‘感谢使用!‘) flag=false; break; } default:console.log(‘输入有误,请重新输入:‘) } } isGister=true; } } if(!isGister) { console.log(‘登录失败,请重新登录‘); inputfalse++; } if(inputfalse==3) { console.log(‘输入次数过多,锁卡‘) break; } }
标签:bsp hang ++ put adl console class pre 使用
原文地址:https://www.cnblogs.com/web--yang/p/9065210.html