首页 > 技术文章 > 实验6 shell程序设计一(2)

double891 2018-05-07 23:10 原文

编写一段bash shell程序,
根据键盘输入的学生成绩,显示相应的成绩登等级,
其中
60分以下为"Failed!",
60~69分为"Passed!",
70~79分为"Medium!",
80~89分为"Good!",
90~100为"Excellent!"。
如果输入超过100的分数,则显示错误分数提示。
 
 
 
#!/bin/bash
while true
do
echo -n "input your score (from 0-100):"
read a
if [ $a -ge 0 -a $a -lt 60 ]
then
echo "Failed"
elif [ $a -lt 70 ]
then 
echo "Passed"
elif [ $a -lt 80 ]
then
echo "Medium!"
elif [ $a -lt 90 ]
then
echo "Good!"
elif [ $a -le 100 ]
then
echo "Excellent!"
else
echo "Sorry,your input is wrong"
exit 1
fi
done
exit 0

 

推荐阅读