首页 > 代码库 > 选择结构2
选择结构2
选择结构还有: switch结构
import java.util.Scanner;
public class Text1{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.println("请输入星期几");
int week=input.nextInt();
switch(week){
case 1:
System.out.println("英语");
break;
case 2:
System.out.println("数学");
break;
case 3:
System.out.println("语文");
break;
case 4:
System.out.println("历史"):
break;
case 5:
System.out.println("政治");
break;
default:
System.out.println("休息");
break;
}
}
}
选择结构2