java流程控制之 switch

package struct;

import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("输入数字 ");

        String next = scanner.next();
        System.out.println("next==》的值为:"+next);


        char grade = 'c';

            switch (grade) {
            case 'a':
                System.out.println("优秀");
                break;
            case 'b':
                System.out.println("良好");
                break;
            case 'c':
                System.out.println("及格");
                break;
            case 'd':
                System.out.println("再接再厉");
                break;
            case 'e':
                System.out.println("挂科");
                break;
            default:
                System.out.println("未知等级");

        }
    }
}

posted @ 2021-07-29 09:38  阿向向  阅读(30)  评论(0编辑  收藏  举报