04-29-2008
6,
0
Join Date: Apr 2008
Last Activity: 4 May 2008, 2:38 PM EDT
Posts: 6
Thanks Given: 0
Thanked 0 Times in 0 Posts
i have that so far this is what i have
#!/usr/bin/ksh
#
#export PATH=/bin:/usr/bin
#
#shell variables
PROG=`basename $0`
#
#OutFile=/tmp/$LOGNAME.$PROG
#
#echo "Hi $LOGNAME:\n\tPlease enter scores of assignments (seperate by 'space'): \c"
read input
echo
#
Counter=0
Total=0
Worst=999
cp/dev/null $OutFile
#
for score in $Input
do
#
case "$score" in
[0-9]|[1-9][0-9]|100)
Counter=`expr $Counter +1`
[$score -it$worst] && Worst=$score
Total=`expr $Total + $score`
echo "\tHw-${Counter}: ${score}, Sum: ${Total}, Worst One: $Worst" | tee-a $OutFile
;;
[0-9]|[1-9][0-9]|100)
echo "\tYou enter <$score> which is greater than 100 ==> no! no!!" >&2
exit 10
;;
*)
echo "\tYou enter <$score> which is not a positve number">&2
exit 20
;;
esac
done
#
echo"
$Counter Assignments Total: ${Total}, Worst: $Worst" | tee-a $OutFile
Conter=`expr $Counter -1`
Total=`expr $Total - $Worst`
Average=`expr $Total/$Counter`
echo"
Average is $Average" | tee-a $OutFile
#
echo "Enter the email id to receive tis report: \c"
read Rcptld
if [-n "Rcptld"]; then
mailx-s "CMP-322 Reportcard" $Rcptld <$OutFile
fi
#
exit 0
but Im still missing the if-then-else-fi command, a case-in-esac, and for/while loop, a trap function, and also a function to check input. And that's what I don't know how to do.