1. 程式人生 > >用Java編寫銀行存錢取錢

用Java編寫銀行存錢取錢

con 輸入密碼 lse 正在 組成 require money one amp

const readline = require(‘readline-sync‘)//引用readline-sync

let s = 2;//錯誤的次數

for (let i = 0; i < 3; i++) {

console.log(‘請輸入名:(由英文組成)‘);

let user = readline.question();

console.log(‘請輸入密碼:(由數字組成)‘);

let password = readline.question();

let arr = [‘yang‘, ‘123456‘];


if (user == arr[0] && password == arr[1]) {

console.log(‘歡迎您,登陸成功‘);

for (let yewu = 1; yewu >= 1; yewu++) {

console.log(‘請選擇業務:\n1.存款: \n2.取款: \n3.查看: \n4.退出:‘);

let yewu = readline.question() - 0;

let money = 3000;

if (yewu > 4) {

console.log(‘對不起你輸入的有誤,請重新輸入:‘)

continue;

}

switch (yewu) {

case 1:

//存款money2為錢變化後的總數

console.log(‘存款‘);

console.log(‘請輸入存款金額:‘);

let cunkuan = readline.question() - 0;

money2 = money + cunkuan;

console.log(‘系統正在為你存錢請稍等。。。。。\n存錢成功您當前余額為‘ + money2);

continue;

case 2:

console.log(‘取款‘);

console.log(‘請輸入取款金額:‘);

let qukuan = readline.question() - 0;

if (qukuan > money2) {

console.log(‘對不起你的余額不足!,您的余額不足,請重新輸入或者退出‘);

} else {

money2 = money2 - qukuan;

console.log(‘當前余額為:‘ + money2);

}

continue;

case 3:

console.log(‘查看‘);

console.log(‘當前你的余額為:‘ + money2);

continue;

case 4:

console.log(‘退出‘);

console.log(‘歡迎你下次使用!‘);

break;

}break;

}

break;

} else {//輸入不正確時

if (s != 0) {

console.log(‘密碼或賬戶名錯誤,您還有‘ + s + "次機會,請重新輸入:");

s--;

continue;

} else {

console.log(‘對不起,賬戶已鎖定!‘);

break;

}

}

}

用Java編寫銀行存錢取錢