数据分析师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.
怪我咯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 "成绩无效"; }