import java.util.*; /** * ATM机java代码 * * @author (webkfa) * @version (webkfa.com) */ public class Account { public static void main(String[] args) { int m = 0; boolean existed = false; while (true) { //显示主菜单 m = displayMenu(); switch (m) { case 1: //使用Account存款功能 break; case 2 : //使用Account取款功能 break; case 3: //使用Account查询余额功能 break; case 4: //new Account break; case 5 : //使用Account销户功能 break; case 0: existed = true; break; default: //报错,提示重新输入 } if (existed) { System.out.println("====================退出成功!!!===================="); break; } } } public static int displayMenu() { System.out.println("====================欢迎使用ATM自助机===================="); System.out.println("1 - 存款"); System.out.println("2 - 取款"); System.out.println("3 - 查询余额"); System.out.println("4 - 开户"); System.out.println("5 - 销户"); System.out.println("0 - 退出"); System.out.print("请选择:"); Scanner in = new Scanner(System.in); int result = in.nextInt(); return result; } }