Menu Based Script in Linux Homework

Write a menu based script which displays the following options :

Accept roll number, name, marks in sub1, sub2 and sub3. Calculate total, percentage, grade & class and enter the record in a file “student”. The marks are out of 100 in each subject. Allow the user to enter any number of records.

Grade is found out as follows :

Percentage              Grade
< 35                            Fail
>= 35 & < 50            Third
>= 50 & < 60            Second
>= 60 & < 75            First
>= 75                   Distn

If the student secures < 35 in any one of the subjects, then class = “fail”.    Otherwise  class=”pass”.

Answer: 

q=y

c=1

while [ $q = 'y' ]

do

echo "enter the name of student $c.. "

read name

echo "enter the roll no of student "

read roll

echo "enter the marks of three subjects out of 100”

read sub1 sub2 sub3

echo "records of $name having roll no. $roll  are as follows... "  >> student

echo "records of $name having roll no. $roll  are as follows..."

if [ $sub1 -le 100 ] && [ $sub2 -le 100 ] && [ $sub3 -le 100 ] | bc

then

if [ $sub1 -lt 35 ] || [ $sub2 -lt 35 ] || [ $sub3 -lt 35 ]

then

 class="fail"

echo "class is $class " >> student

echo "class is $class "

else

class=”pass”

echo "class is $class " >> student

echo "class is $class "

fi

tot=`expr $sub1 + $sub2 + $sub3`

echo "total is $tot " >> student

echo "total is $tot "

per=`expr $tot / 3`

echo "percentage is $per % " >>student

echo "percentage is $per % "

if [ $per -lt 35]

then

grade="fail"

echo "grade is $grade " >> student

echo "grade is $grade "

elif [ $per -ge 35 ] && [ $per -lt 50

then

grade="third"

echo " grade is $grade " >> student

 echo " grade is $grade"

elif [ $per -gt 60 ] && [ $per -lt 75 ]

then

grade="first"

echo "grade is $grade " >> student

echo "grade is $grade "

else

grade="distn"

echo " grade is $grade " >> student

echo " grade is $grade "

fi

else

echo "incorrect data  "

c=`expr $c - 1` #decrease one in the counter for the incorrect data

fi

echo " continue..[y/n].. "

read q

c=`expr $c + 1` #increase one in the counter

done

echo "bye bye.. "

Linux Tips

See Also
ACL Setting For User On Directory

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Home Index
Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.