1.if结构
if(boolean){
语句块;
}
int age=20;
if(age>18){
System.out.println("成年人");
}
2.if...else结构
if(boolean){
语句块1;
}else{
语句块2;
}
int score=90;
if(score>=60){
System.out.println("合格");
}else{
System.out.println("不合格");
}
3.if...else if结构
if(boolean){
语句块1;
}else if(boolean){
语句块2;
}else{
语句块3;
}
int score=90;
if(score>=100||score<=0){
System.out.println("成绩不合法")
}else if(score>60){
System.out.println("成绩合格");
}else{
System.out.println("不合格");
}
4.switch...case
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
switch(a){
case 1: System.out.println("存款");break;
case 2: System.out.println("查询");break;
default: System.out.println("输入不合法");
}