JAVA学习笔记4

学习目标:

精通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

学习产出:

同学习内容

  • 17
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值