linux下bash程序的问题
输入分数,判断等级,60-69为D,70-79为C,80-89为B,90-100为A,60以下为FAIL,其他错误输出报错。。。。用if语句,谁会写啊???...
输入分数,判断等级,60-69为D,70-79为C,80-89为B,90-100为A,60以下为FAIL,其他错误输出报错。。。。用if语句,谁会写啊???
展开
展开全部
#!/bin/bash
echo Please input your score:
read score
if [ $score -ge 60 -a $score -le 69 ]
then output="D"
elif [ $score -ge 70 -a $score -le 79 ]
then output="C"
elif [ $score -ge 80 -a $score -le 89 ]
then output="B"
elif [ $score -ge 90 -a $score -le 100 ]
then output="A"
elif [ $score -lt 60 ]
then output="Fail"
else
output="Error"
fi
echo $output
echo Please input your score:
read score
if [ $score -ge 60 -a $score -le 69 ]
then output="D"
elif [ $score -ge 70 -a $score -le 79 ]
then output="C"
elif [ $score -ge 80 -a $score -le 89 ]
then output="B"
elif [ $score -ge 90 -a $score -le 100 ]
then output="A"
elif [ $score -lt 60 ]
then output="Fail"
else
output="Error"
fi
echo $output
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询