续前面的switch语句

public class Switch3{
    public static void main(String[] args){
    //接收用户输入
    java.util.Scanner n = new java.util.Scanner(System.in);
    //    提示用户输入
    System.out.print("请输入您的成绩:");
    double chengji = n.nextDouble();
    //划分成绩
    if (chengji < 0 || chengji >100){
        System.out.println("输入有误!");
        return;
    }
    
    //把分数强转为int类型才能代入switch语句
    int dengji = (int)(chengji/10);//成绩除以10以后强转int类型
    //用switch划分成绩等级
    switch(dengji){
        case 9: case 10:
            System.out.println("优秀");
            break;
        case 8:
            System.out.println("l良");
            break;
        case 7:
            System.out.println("中");
            break;
        case 6:
            System.out.println("及格");
            break;

        case 1:case 2:case 3: case 4:case 5:

            System.out.println("不及格");
            break;
    }

    }
}

续第一次写switch语句的简介续写

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2021-08-14
  • 2021-05-26
  • 2021-10-22
  • 2021-06-30
  • 2021-07-18
  • 2021-12-30
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2021-09-23
  • 2021-08-12
  • 2021-04-07
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案