search

Home  >  Q&A  >  body text

假设学生的成绩范围在0到100分,规定90-100为A级,80-89为B级,70-79为C级,60-69为D级,0-59为E级,请编写程序输出结果。(先判断成绩是否为有效值,再判断等级)?

这是啥这是啥2838 days ago3648

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:29:13

    Assume that the student's score ranges from 0 to 100. It is specified that 90-100 is level A, 80-89 is level B, 70-79 is level C, 60-69 is level D, and 0-59 is level E. Please write a program to output the results. (First determine whether the score is a valid value, and then determine the grade)? - PHP Chinese website Q&A - Assume that the student's score ranges from 0 to 100 points. It is stipulated that 90-100 is A grade, 80-89 is B grade, and 70-79 is Level C, 60-69 is level D, 0-59 is level E. Please write a program to output the results. (First determine whether the score is a valid value, and then determine the level)? - PHP Chinese website Q&A

    Take a look and learn.

    reply
    0
  • 怪我咯

    怪我咯2017-02-22 14:50:35

    仅供参考

    if($grades>=0 and $grades<=100){
            switch($grades){
                    case $grades<=100 and $grades >=90 :
                    echo "成绩等级为A";
                    break;
            
                    case $grades<90 and $grades >=80 :
                    echo "成绩等级为B";
                    break;
                    
                    case $grades<80 and $grades >=70 :
                    echo "成绩等级为C";
                    break;
                    
                    case $grades<70 and $grades >=60 :
                    echo "成绩等级为D";
                    break;
            
                    default :
                    echo "成绩为E";
    }
    }else{
            echo "成绩无效";
    }


    reply
    0
  • Cancelreply