Article From:https://www.cnblogs.com/yehongrun/p/9060062.html
console.log(“Please enter the name of the username: “);
let username = readline.question();   // The username received by the user
console.log(“Please enter the password: “);
let password = readline.question();      // The password received by the user
let arr = [[“123”, “123”], [“456”, “456”], [“789”, “789”]];   // Registered database
let a = false;  // State value, state of logon
let dlsb = true;  // Landing failure cycle
let bj = 10000;  //The definition of a principal is 10000 yuan

// Sign in
for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr[i].length; j++) {
        if (arr[i][0] === username && arr[i][1] === password) {     // Determine whether the username and password are consistent
            // console.log(“Logon success “);
            a = true;
            // function
            let tccx = true; // Define a state value to exit the loop
            while (tccx) {
                // Functional hints
                let qk = “1.Withdrawals, “CK =” 2. deposit, “CX =” 3. inquires the remaining amount, “TC =” 4. withdraws;
                console.log(qk, ck, cx, tc);
                let cz = readline.question();
                switch (cz) {
                    case “1”: {
console.log(“Please enter the amount of withdrawals: “);
                        let qkje = readline.question() – 0;
                        console.log(`Determine withdrawal: ${qkje} yuan?
                        console.log(“For confirmation, please input 1, cancel withdrawals, please enter 2. “);
                        let qdqk = readline.question();
                        if (qkje > bj) {
                            console.log(“I’m sorry, you can’t make a withdrawal from your balance. “);
                        } else {
                            switch (qdqk) {
                                case “1”: {
                                    bj -= qkje;
                                    console.log(“You have successfully withdrawed “+ qkje +” yuan, remaining “+ BJ +” yuan. “);
                                    break;
                                }
                                case “2”: {
                                    console.log(“You have canceled this operation. “);
                                    break;
                                }
                            }
                        }
                        break;
                    }

                    case “2”: {
                        console.log(“Please input the amount of the deposit: “);
                        let qkje = readline.question() – 0;
                        console.log(`Determine deposit: ${qkje} yuan?
                        console.log(“For confirmation of deposit, please enter 1, cancel the deposit, please enter 2. “);
                        let qdqk = readline.question();
                        switch (qdqk) {
                            case “1”: {
                                bj += qkje;
                                console.log(“You have successfully deposit “+ qkje +” yuan, remaining “+ BJ +” yuan. “);
                                break;
                            }
                            case “2”: {
                                console.log(“You have cancelled the operation. “);
                                break;
                            }
                        }
                        break;
                    }
                    case “3”:
                        console.log(“Your remaining amount is: “+ BJ +” Yuan “);
                        break;
                    case “4”: {
                        console.log(“Thank you for your use, and welcome to use it next time.
                        tccx = false;
                        break;
                    }
                    default:
                        console.log(“After checking, enter the corresponding content.
                }
            }
            break;
        }
        break;
    }
    break;
}
if (a == false) {
    let jx = true;  // The state value, used in the following while loop

    console.log(“The user name or password is incorrect, please check it and enter it. If you enter the error 2 times, you will automatically freeze the account. Do you continue to enter? Please continue to enter 1, exit and enter 2. “);
    let sfjx = readline.question();  // Let the user decide whether to continue
    let srcs = 1; // Input times
    switch (sfjx) {
        case “1”: {
            while (srcs) {
                console.log(“Please enter the username “).
                username = readline.question();
                console.log(“Please enter the password “).
                password = readline.question();
                srcs++;

                for (let i = 0; i < arr.length; i++) {
                    for (let j = 0; j < arr[i].length; j++) {
                        if (arr[i][0] === username && arr[i][1] === password) {     // Determine whether the username and password are consistent
                            // console.log(“Logon success “);
                            srcs = 0;

                            // function
                            let tccx = true; // Define a state value to exit the loop
                            while (tccx) {
                                // Functional hints
                                let qk = “1.Withdrawals, “CK =” 2. deposit, “CX =” 3. inquires the remaining amount, “TC =” 4. withdraws;
                                console.log(qk, ck, cx, tc);
                                let cz = readline.question();
                                switch (cz) {
                                    case “1”: {
                                        console.log(“Please enter the amount of withdrawals: “);
                                        let qkje = readline.question() – 0;
                                        console.log(`Determine withdrawal: ${qkje} yuan?
                                        console.log(“For confirmation, please input 1, cancel withdrawals, please enter 2. “);
                                        let qdqk = readline.question();
                                        if (qkje > bj) {
                                            console.log(“I’m sorry, you can’t make a withdrawal from your balance. “);
                                        } else {
                                            switch (qdqk) {
                                                case “1”: {
                                                    bj -= qkje;
                                                    console.log(“You have successfully withdrawed “+ qkje +” yuan, remaining “+ BJ +” yuan. “);
                                                    break;
                                                }
                                                case “2”: {
                                                    console.log(“You have canceled this operation. “);
                                                    break;
                                                }
                                            }
                                        }
                                        break;
                                    }

                                    case “2”: {
                                        console.log(“Please input the amount of the deposit: “);
                                        let qkje = readline.question() – 0;
                                        console.log(`Determine deposit: ${qkje} yuan?
                                        console.log(“For confirmation of deposit, please enter 1, cancel the deposit, please enter 2. “);
                                        let qdqk = readline.question();
                                        switch (qdqk) {
                                            case “1”: {
                                                bj += qkje;
                                                console.log(“You have successfully deposit “+ qkje +” yuan, remaining “+ BJ +” yuan. “);
                                                break;
                                            }
                                            case “2”: {
                                                console.log(“You have cancelled the operation. “);
                                                break;
                                            }
                                        }
                                        break;
                                    }
                                    case “3”:
                                        console.log(“Your remaining amount is: “+ BJ +” Yuan “);
                                        break;
                                    case “4”: {
                                        console.log(“Thank you for your use, and welcome to use it next time.
                                        tccx = false;
                                        break;
                                    }
                                    default:
                                        console.log(“After checking, enter the corresponding content.
                                }
                            }
                            break;
                        }
                        break;
                    }
                    break;
                }
                if (srcs == 3) {
                    console.log(“The user name or password you entered is more than 3 times incorrect, automatically freezing the account. “);
                    break;
                }
            }
        }
        case “2”: {
            jx = false;
            break;
        }
    }
}

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *