JavaScript Analog ATM Service

Source: Internet
Author: User
Tags readline

Const ReadLine = require ("Readline-sync"); let time= 0;//number of passwords lostLet x = 1;//Temp VariableConsole.log ("Please enter your password"); let password= Readline.question ()-0; while(Password! = 123456) {Console.log ("The password you entered is incorrect, please re-enter"); Password= Readline.question ()-0; time++; if(Time = = 2) {Console.log ("Password three times error, card is locked");  Break; }}//the above to confirm the password is correctif(Password = = 123456) {Let balance= 2000;//default in-card balance is 2000     while(x = = 1) {Console.log ("Please select a business"); Console.log ("1. Deposit"); Console.log ("2. Withdrawals"); Console.log ("3. View"); Console.log ("4. Exit"); Let check= Readline.question ()-0;  while(IsNaN (check) | | Check < 1 | | Check > 4) {Console.log ("Please re-lose"); Check= Readline.question ()-0; }        if(Check = = 4) {Console.log ("Thanks for using, goodbye");  Break; }        if(Check = = 3) {console.log (' bank card balance is ${balance} yuan '); Console.log ("Exit Press 1 to return to the main menu, press 2"); Let get= Readline.question ()-0;  while(IsNaN (GET) | | Get < 1 | | Get > 2) {Console.log ("Please re-lose"); Get= Readline.question ()-0; }            if(Get = = 1) {Console.log ("Thanks for using, goodbye"); X++; }        }         while(Check = = 2) {            if(Balance = = 0) {Console.log ("Please note that Cary has no money."); Console.log ("Exit Press 1 to return to the main menu, press 2"); Let Choice2= Readline.question ()-0;  while(IsNaN (choice2) | | Choice2 < 1 | | Choice2 > 2) {Console.log ("Please re-lose"); Choice2= Readline.question ()-0; }                if(Choice2 = = 1) {Console.log ("Thanks for using, goodbye"); X++;  Break; }Else{                     Break; }} console.log ("Please enter the withdrawal amount:"); Let Drawmoney= Readline.question ()-0;  while(IsNaN (Drawmoney) | | Drawmoney < 0 | | Drawmoney > 20000) {Console.log ("A single withdrawal must not exceed 20,000, please enter the correct number"); Drawmoney= Readline.question ()-0; } Let H=balance;//Temp Variable             while(Drawmoney >h) {Console.log ("The withdrawal amount exceeds the balance, please re-enter"); Drawmoney= Readline.question ()-0; } Balance-=Drawmoney;            Console.log (' Withdrawal amount is ${drawmoney} yuan, card remaining ${balance} Yuan '); Console.log ("Please press 1 to withdraw, press 2 to return to the main menu, press 3"); Let Choice1= Readline.question ()-0;  while(IsNaN (Choice1) | | Choice1 < 1 | | Choice1 > 3) {Console.log ("Please re-lose"); Choice1= Readline.question ()-0; }            if(Choice1 = = 1) {Console.log ("Thanks for using, goodbye"); X++;  Break; }Else if(Choice1 = = 2) {Check= = 2; }Else{                 Break; }        }         while(Check = = 1) {Console.log ("Please enter the deposit amount:"); Let Savemoney= Readline.question ()-0;  while(IsNaN (Savemoney) | | Savemoney < 0 | | Savemoney > 50000) {Console.log ("A single deposit must not exceed 50,000, please enter the correct number"); Savemoney= Readline.question ()-0; } Balance+=Savemoney;            Console.log (' Deposit amount is ${savemoney} yuan, card remaining ${balance} Yuan '); Console.log ("Exit please press 1, continue deposit please press 2, return to main menu please press 3"); Let Choice= Readline.question ()-0;  while(IsNaN (choice) | | Choice < 1 | | Choice > 3) {Console.log ("Please re-lose"); Choice= Readline.question ()-0; }            if(Choice = = 1) {Console.log ("Thanks for using, goodbye"); X++;  Break; }Else if(Choice = = 2) {Check= = 1; }Else{                 Break; }        }    }}

JavaScript Analog ATM Service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.