Linux Shell Script Program to Create Student Marksheet

Linux shell script program to find student grade entered by the user.

This is the exact question that was in the GUJARAT TECHNOLOGICAL UNIVERSITY MCA SEMESTER III

Q. Script should run using command line and without it.Write script which will take marks of 3 subjects and display Grade (use GTU Grade guide lines).

Here is the exact working program. Tested on the system

Linux Shell Script Program to Create Student Marksheet
Linux Shell Script Program to Create Student Marksheet

 

if [ $# -eq 0 ]
 then

echo "Enter Java Marks :"
 read m1
 echo "Enter Oprating System Marks :"
 read m2
 echo "Enter Advance Java Marks :"
 read m3
 else
 m1=$1
 m2=$2
 m3=$3
 fi
 tot=`echo $m1 + $m2 + $m3|bc`
 per=`echo $tot/3|bc`

echo "\n\n"
 echo "========================================"
 echo " Student Marksheet "
 echo "========================================"
 #echo " Student Number : $no "
 echo " Student Marks : $m1 "
 echo " Student Marks : $m2 "
 echo " Student Marks : $m3 "
 echo "========================================"
 echo " Total : $tot "
 echo " Percentage $per "
 echo "========================================"

if [ $per -ge 80 ]
 then
 echo "Grade AA"
 elif [ $per -ge 70 -a $per -lt 80 ]
 then
 echo "Grade AB"
 elif [ $per -ge 60 -a $per -lt 70 ]
 then
 echo "Grade BB"
 elif [ $per -ge 50 -a $per -lt 60 ]
 then
 echo "Grade BC"
 elif [ $per -ge 40 -a $per -lt 50]
 then
 echo "Grade CC"
 else
 echo "Grade FF"
 fi
OutPut

 

I assume you know how to run this program 😀

Here is the sh extension program to run directly on your linux terminal