Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Friday, 30 March 2012

Write a script for generating a mark sheet after reading data from a file. File contains student roll no, name , marks of three subjects.


len=`cat student.txt | wc -l`
i=1
echo "\n\n\tSTUDENT MARKSHEET"
echo "\t=================\n"
echo "NAME \t \t TOTAL \t \t PERCENTAGE"
echo "====================================================="
while [ $i -le $len ]
do
record=`head -n $i student.txt | tail -n 1`
total=0
for (( j=2 ; $j < 5 ; j=`expr $j + 1` ))
do
marks=`echo $record | cut -d " " -f $j`
total=`expr $total + $marks`
done
name=`echo $record | cut -d " " -f 1`
per=`expr $total / 3`
echo "$name \t \t $total \t \t $per %"
i=`expr $i + 1`
done

No comments:

Post a Comment