假设一个简单的在AT
public static void main(String[] args) { Scanner in = new Scanner(System.in); for (int i = 0; i < 3; i++) { System.out.print("请输入密码:"); int pwd = in.nextInt(); if (pwd == 111111) { System.out.print("请输入取款的金额:"); int amount = in.nextInt(); for (int j = 1; j <3; j++) { if (amount % 100 == 0 && amount <= 1000) { System.out.println("您取了" + amount + "元"); System.out.println("交易完成!请取卡!"); return; } else { System.out.print("您输入的金额不合法!请重新输入:"); amount = in.nextInt(); continue; } } break; } } System.out.println("密码错误!请取卡!"); }
M取款过程: