public static void main(String[] args) { in = new Scanner(System.in); int count = 1; int pwd = 111111; while (true) { System.out.println("请输入密码:"); int pwssword = in.nextInt(); count++; if (count > 3) { System.out.println("密码错误,请取卡!"); return; } if (pwssword == pwd) { break; } else System.out.println("密码错误,请重新输入密码:"); } int sum = 0, money = 0; char p = 'Y'; first: while (p == 'Y') { System.out.println("请输入0~6之间数字:"); System.out.println("0、手动输入金额\t1、100\t2、300\t3、500\t4、1000\t5、3000\t6、5000"); int num = in.nextInt(); switch (num) { case 0: System.out.println("手动输入金额:"); money = in.nextInt(); if (money <= 1000 && money >= 0 && money % 100 == 0) { break; } else { System.out.println("金额错误,是否继续Y/N"); p = in.next().charAt(0); if (p == 'Y') { continue; } else { break first; } } case 1: money = 100; break; case 2: money = 300; break; case 3: money = 500; break; case 4: money = 1000; break; case 5: money = 3000; break; case 6: money = 5000; break; default: System.out.println("输入错误,是否继续Y/N"); p = in.next().charAt(0); if (p == 'N') { break first; } else { continue; } } sum += money; if (sum < 20000) { System.out.println("本次取款" + money + "元"); System.out.println("共取钱" + sum + "元"); System.out.println("取款完成,是否继续Y/N"); p = in.next().charAt(0); } else if (sum == 20000) { System.out.println("今日取钱已达上限20000,请退卡"); break; } else { sum = sum - money; System.out.println("取款失败"); System.out.println("共取钱" + (sum) + "元"); System.out.println("还可以取款" + (20000 - sum) + "元"); System.out.println("是否继续Y/N"); p = in.next().charAt(0); continue; } } }