成绩等级统计

写一段bash shell,从键盘输入学生成绩,显示相应的等级。。。

可以输入多个,用空格隔开即可


#!/bin/bash
#by zy
function iscontinue()
{
while true
do
echo -n "continue?(Y/N)"
read op
case $op in
[Yy]) return 0;;
[Nn]) return 1;;
*)echo "enter y or n"
esac
done
}
echo "This is a score judgement bash!"
while true
do
echo -n "Please enter the guys' score: "
read score
a=($score)
len=${#a[@]}
for((j=0;j<"$len";j=j+1))
do
if [ "${a[$j]}" -gt 100 ];
then
echo -n "the score is"
echo " is grater than 100!Error!"
else
case ${a[$j]} in
100|9[0-9]) echo "excellent!";;
8[0-9]) echo "Good!";;
7[0-9]) echo "Medium!";;
6[0-9]) echo "Passed!";;
[0-9]|[0-5][0-9]) echo "Fuck!u r failed";;
*) 
echo "error!"
;;
esac
fi
done
if iscontinue
then
continue
else
break
fi
done
exit 


posted @ 2013-11-05 07:35  Fresher_Z  阅读(159)  评论(0编辑  收藏  举报