switch处理多分支结构
import java.util.Scanner; /** * Created by liwenj on 2017/7/17. */ public class test9 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("1.登录系统"); System.out.println("2.退出系统"); System.out.print("请输入数字:"); int check=input.nextInt(); switch (check){ case 1: System.out.println("主菜单"); System.out.println("1.客户信息管理"); System.out.println("2.购物结算"); System.out.println("3.回馈"); System.out.println("4.退出"); System.out.println("请输入数字"); int op=input.nextInt(); switch (op){ case 1: System.out.println("1.添加客户信息"); System.out.println("2.修改客户信息"); break; case 2: System.out.println("1.幸运抽奖"); System.out.println("2.生日问候"); } break; case 2: System.exit(1);//退出程序 } } }