Package com.eduask.test;
Import Java.util.Scanner;
public class ATM {
Static double money=0.0;//Create an account with an amount of 0.0
public static void Main (string[] args) {
Scanner sc=new Scanner (system.in);
for (;;) {
System.out.println ("Welcome to love to save the bank");
SYSTEM.OUT.PRINTLN ("Please select transaction type: 1 Save 2 withdraw money 3 Check balance 4 exit");
int Num=sc.nextint ();
if (num==1) {
System.out.println ("Your deposit amount is:");
Double m=sc.nextdouble ();
Add (m);
}else if (num==2) {
SYSTEM.OUT.PRINTLN ("Your withdrawal amount is:");
Double m=sc.nextdouble ();
if (M>money) {
SYSTEM.OUT.PRINTLN ("Insufficient balance");
}else{
if (m%100==0) {
Jian (m);
}else{
SYSTEM.OUT.PRINTLN ("The machine only provides 100 yuan par access");
}
}
}else if (num==3) {
Query ();
}else{
Break
}
}
}
/**
* Save money
*/
public static void Add (double m) {
Money+=m;
}
/**
* Withdraw Money
*/
public static void Jian (double m) {
Money-=m;
}
/**
* Check Balance
*/
public static void query () {
System.out.println ("Your balance is:" +money);
}
}
Java ATM take money code