学习目标:
精通JAVA
学习内容:
//顺序语句
public class Demo01Sequence{
public static void main(String[] args){
System.out.println(“今天天气真好!”);
System.out.println(“适合打羽毛球哦!”);
}
}
public class Demo02If{
public static void main(String[] args){
System.out.println(“今天天气不错,出门上网”);
int age =19;
if (age>=18){
System.out.println(“去打撸啊撸”);
}
System.out.println(“回家吃饭”);
}
}
public class Demo03IfElse{
public static void main(String[] agrs){
int a = 4;
if (a%2==0){
System.out.println(“a是偶数”);
}else{
System.out.println(“a是奇数”);
}
}
}
public class Demo05IfElse{
public static void main(String[] agrs){
int score = 98;
if (score <= 100&&score >= 90){
System.out.println(“优秀”);
} else if (score >= 80 && score < 90){
System.out.println(“好”);
} else if (score >= 70 && score < 80){
System.out.println(“良”);
} else if (score >=60 && score < 70){
System.out.println(“及格”);
} else if (score < 60 && score >= 0 ){
System.out.println(“不及格”);
} else {
System.out.println(“数据不合理”);
}
}
}
5.if语句判断最大值
public class Demo02Max{
public static void main(String[] args){
/int a = 20;
int b = 10;
int max = a > b ? a : b;
System.out.println(“最大值是” + max);/
int a = 20;
int b = 105;
int max;
if(a > b){
max = a;
} else {
max = b;
}
System.out.println(“最大值是”+max);
}
}
6.switch语句
public class Demo07Switch{
public static void main(String[] args){
int num1 = 10;
switch (num1) {
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;
case 6:
System.out.println(“星期六”);
break;
case 7:
System.out.println(“星期日”);
break;
default:
System.out.println(“数据错误”);
break;
}
}
}
学习时间:
20240520
学习产出:
同学习内容