if的第一二三种语句分析
作者:互联网
public class OperatorDemo{
public static void main(String[]args){
System.out.println("开始");
int a=10;
int b=10;
if(a==b){
System.out.println("a等于b");
}else{
System.out.println("a不等于b");
}
System.out.println("结束");
}
//}
public class OperatorDemo{
public static void main(String[]args){
System.out.println("开始");
Scanner sc = new Scanner (System.in);
System.out.println("请输入一个星期(1-7):");
int week = sc.nextInt();
if (week == 1){
System.out.println("星期一");
}else if(week == 2){
System.out.println("星期二");
}else if(week == 3){
System.out.println("星期三");
}else if(week == 4){
System.out.println("星期四");
}else if(week == 5){
System.out.println("星期五");
}else if(week == 6){
System.out.println("星期六");
}else if(week == 7){
System.out.println("星期日");
System.out.println("结束");
}
}
}
标签:语句,week,第一二,System,else,三种,println,public,out 来源: https://blog.csdn.net/Running6666/article/details/121375908