Write a script for generating a mark sheet after reading data from a file. File contains student roll no, name , marks of three subjects.
studInfo.txt
hitesh,30,70,80
mitesh,30,80,40
jitesh,30,35,40
ritesh,100,100,100
mitesh,30,80,40
jitesh,30,35,40
ritesh,100,100,100
Ex13.sh
clear
len=`cat studInfo.txt | wc -l`
i=1
echo "\n\n\t\t\t [ STUDENT MARKSHEET ]\n"
echo "__________________________________________________________________________"
echo "#\t NAME \t \t \t TOTAL \t \t PERCENTAGE \t GRADE "
echo "__________________________________________________________________________"
while [ $i -le $len ]
do
record=`head -n $i studInfo.txt | tail -n 1`
total=0
j=2
isFail=0
while [ $j -le 4 ]
do
marks=`echo $record | cut -d "," -f $j`
if [ $marks -lt 40 ]
then
isFail=1
fi
total=`expr $marks + $total`
j=`expr $j + 1`
done
name=`echo $record | cut -d "," -f 1`
per=`expr $total / 3`
if [ $isFail = 0 ]
then
if [ $per -ge 85 ] && [ $per -le 100 ]
then
grade="AA"
elif [ $per -ge 75 ] && [ $per -le 84 ]
then
grade="AB"
elif [ $per -ge 65 ] && [ $per -le 74 ]
then
grade="BB"
elif [ $per -ge 55 ] && [ $per -le 64 ]
then
grade="BC"
elif [ $per -ge 45 ] && [ $per -le 54 ]
then
grade="CC"
else
grade="FF"
fi
else
grade="FF"
fi
echo "$i \t $name \t \t $total \t \t $per % \t \t $grade"
i=`expr $i + 1`
done
echo "__________________________________________________________________________\n"
len=`cat studInfo.txt | wc -l`
i=1
echo "\n\n\t\t\t [ STUDENT MARKSHEET ]\n"
echo "__________________________________________________________________________"
echo "#\t NAME \t \t \t TOTAL \t \t PERCENTAGE \t GRADE "
echo "__________________________________________________________________________"
while [ $i -le $len ]
do
record=`head -n $i studInfo.txt | tail -n 1`
total=0
j=2
isFail=0
while [ $j -le 4 ]
do
marks=`echo $record | cut -d "," -f $j`
if [ $marks -lt 40 ]
then
isFail=1
fi
total=`expr $marks + $total`
j=`expr $j + 1`
done
name=`echo $record | cut -d "," -f 1`
per=`expr $total / 3`
if [ $isFail = 0 ]
then
if [ $per -ge 85 ] && [ $per -le 100 ]
then
grade="AA"
elif [ $per -ge 75 ] && [ $per -le 84 ]
then
grade="AB"
elif [ $per -ge 65 ] && [ $per -le 74 ]
then
grade="BB"
elif [ $per -ge 55 ] && [ $per -le 64 ]
then
grade="BC"
elif [ $per -ge 45 ] && [ $per -le 54 ]
then
grade="CC"
else
grade="FF"
fi
else
grade="FF"
fi
echo "$i \t $name \t \t $total \t \t $per % \t \t $grade"
i=`expr $i + 1`
done
echo "__________________________________________________________________________\n"
Labels:
shell script,
unix
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
0 comments:
Post a Comment