day05

if else switch判断结构

  1. if结构
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        if (x>=90 && x<=100){
            System.out.println("优秀");
        }else if (x>=80 && x<90){
            System.out.println("良");
        }else if (x>=70 && x<80){
            System.out.println("中");
        }else if (x>=60 && x<70){
            System.out.println("及格");
        }else if (x<60 && x>=0){
            System.out.println("不及格");
        }else {
            System.out.println("输入的成绩不合法");
        }
    }
}

public class Demo03 {
    public static void main(String[] args) {
        if(false)   //if else 语句末尾没有大破号的情况下 默认第一句就是执行体
                System.out.println("666");
        else
                System.out.println("777");

    }
}   
  1. switch结构

    import java.util.Scanner;
    
    public class Demo007 {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            String message = scanner.next();//可以使用String类型
    
            switch (message){
                case "我是臭保底人":
                    System.out.println("我是阿斯托洛吉斯·莫娜·梅姬斯图斯");break;
                case "我是欧皇":
                    System.out.println("以理服人大棒");break;
                case "单抽出奇迹":
                    System.out.println("劳逸结合是不错,但也不要放松过头(爬)");break;
                case "退坑了退坑了":
                    System.out.println("十连全金");break;
                default:
                    System.out.println("胡桃池出刻晴");break;
    
            }
        }
    }
    
    
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值