Code:
echo "Enter the marks of five subjects : "
read m1 m2 m3 m4 m5
let per=$m1+$m2+$m3+$m4+$m5
let per=per/5
echo "Percentage of students is $per %"
if [ $per -lt 35 ]
then
echo "Student Failed."
elif [ $per -ge 35 -a $per -lt 45 ]
then
echo "Student passed with third class."
elif [ $per -ge 45 -a $per -lt 60 ]
then
echo "Student passed with second class."
elif [ $per -ge 60 -a $per -lt 75 ]
then
echo "Student passed with first class."
fi
Output:
[ty2011330@localhost ~]$ sh j05.sh
Enter the marks of five subjects :
20 15 32 14 34
Percentage of students is 23 %
Student Failed.
[ty2011330@localhost ~]$ sh j05.sh
Enter the marks of five subjects :
35 45 35 36 40
Percentage of students is 38 %
Student passed with third class.
[ty2011330@localhost ~]$ sh j05.sh
Enter the marks of five subjects :
50 55 45 56 60
Percentage of students is 53 %
Student passed with second class.
[ty2011330@localhost ~]$ sh j05.sh
Enter the marks of five subjects :
60 78 89 96 47
Percentage of students is 74 %
Student passed with first class
No comments:
Post a Comment