Chapter 8 Exercises

//ATM withdrawal simulation

public static void ATM() {

int password = 0;// password
int amount = 0;// amount
System.out.print("Please enter password:");
Scanner input = new Scanner(System.in);
password=input.nextInt();
while (password != 111111) {
System.out.print("The password is incorrect, please re-enter the password:");
Scanner input2 = new Scanner(System.in);
password = input2.nextInt();
}
System.out. print("Please enter the amount:");
Scanner input3 = new Scanner(System.in);
amount=input3.nextInt();
while (amount > 1000 && amount >= 0) {
System.out.print("You enter The amount is invalid, please re-enter the amount:");
Scanner input2 = new Scanner(System.in);
amount=input2.nextInt();
}
System.out.println("You have taken:"+amount);
System.out.println("The transaction is completed, please take the card");
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325911571&siteId=291194637