The preliminary implementation of the Java---ATM teller machine

Source: Internet
Author: User

Through the Java language, the use of methods, the initial realization of ATM ATM basic functions.

Import Java.util.Scanner;

public class ATM2 {

public static void Main (string[] args) {
TODO auto-generated Method Stub
Loginsystem ();
}

Login System Method:
public static void Loginsystem () {
Scanner scan = new Scanner (system.in);
System.out.println ("*******************************");
SYSTEM.OUT.PRINTLN ("******** Welcome to Huaxia First Bank!*********");
System.out.println ("*******************************");
int i=0;
for (i = 0;i<3;i++) {
System.out.println ("Please enter your account number:");
String username = Scan.nextline ();
System.out.println ("Please enter your password:");
String password = scan.nextline ();
if (Username.equals ("J145") &&password.equals ("HRWSMV")) {
System.out.println ("Congratulations, landing success!") ");
OS ();
Break
}else{
if (i<2) {
System.out.println ("Account or password error, you also have" + (2-i) + "Opportunity Please re-enter:");
}
}
}
if (i==3) {
SYSTEM.OUT.PRINTLN ("You have entered the error three times and the card has been confiscated, please contact the staff.") ");
}
}

Operating system methods:
public static void OS () {
while (true) {
Scanner scan = new Scanner (system.in);
SYSTEM.OUT.PRINTLN ("Please choose your operation: 1, check the balance, 2, withdraw money, 3, save, 4, change the password; 5, exit.") ");
int choice = Scan.nextint ();
Switch (choice) {
Case 1:
System.out.println ("Your account balance: 1000000.00 yuan");
Break
Case 2:
Takemoney ();
Break
Case 3:
Savemoney ();
Break
Case 4:
ChangePassword ();
Break
Case 5:
System.out.println ("Thanks for using, goodbye!");
Return
Default:
System.out.print ("Your input is not correct, please re-enter:");
}
}
}
How to withdraw money:
public static void Takemoney () {
while (true) {
Scanner scan = new Scanner (system.in);
System.out.println ("Please enter your withdrawal amount:");
int Takemoney = Scan.nextint ();
if (takemoney% 100 ==0) {
System.out.println ("Please take your money if you are successful.") ");
System.out.println ("Your balance is" + (1000000.00-takemoney) + "Yuan");
Break
}else {
SYSTEM.OUT.PRINTLN ("Your input is not correct, please re-enter!");
}
}
}
How to save money:
public static void Savemoney () {
Scanner scan = new Scanner (system.in);
while (true) {
System.out.println ("Please put your deposit note (must be for the whole hundred banknotes, please do not fold)");
int Savemoney = Scan.nextint ();
if (savemoney% 100 ==0) {
System.out.println ("Congratulations on your saving success, please continue with your operation.") ");
Break
}else {
System.out.println ("You put the bill is not correct, please re-put!");
}
}
}

The preliminary implementation of the Java---ATM teller machine

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.