|
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
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.. " |
|
See Also
Have a Linux Problem
Linux Books
Home Index
(c) www.gotothings.com All material on this site is Copyright.
|