#!/bin/bash

if [ $# -eq 0 ]
then
  read -p "Please enter a grade: " grade
elif [ $# -eq 1 ]
then
  grade=$1
else
   echo "USAGE: $0 [mark %]" >&2
   exit 1
fi


until echo $grade | grep -q "^[0-9][0-9]*$"
do
  echo "Error: invalid number" >&2
  read -p "Please re-enter a VALID number: " grade
done




if [ $grade -ge 80 ]
then
   grade=A
elif [ $grade -ge 70 ]
then
   grade=B
elif [ $grade -ge 60 ]
then
   grade=C
elif [ $grade -ge 50 ]
then
   grade=D
else
   grade=F
fi

echo "Your grade is $grade"






