switch多分支结构 Branch.java
import java.util.*;
public class Branch{
//switch多分支结构
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入你的名次");
int mingci=in.nextInt();
/*
if(mingci==1) {
System.out.println("出任武林盟主");
}
if(mingci==2){
System.out.println("出任武当掌门");
}
if(mingci==3){
System.out.println("出任峨眉掌门");
}
if(mingci>3){
System.out.println("逐出师门");
}
*/
switch(mingci){
case 1:
System.out.println("出任武林盟主");
break;
case 2:
System.out.println("出任武当掌门");
break;
case 3:
System.out.println("出任峨眉掌门");
break;
default:
System.out.println("逐出师门");
}
}
}