This question already has an answer here:
I am working on my unix homework and I get an error if I enter a grade higher then 59.
Enter a numeric grade number when prompted "Please enter your grade " and receive the message "You got a(n) ", where grade is the letter grade you earned.
#!/bin/bash
echo "Enter your grade"
read grade
echo "Grade: " $grade
if [ $grade -le 59 ]
then
echo "You got an F"
elif [ $grade -ge 60 ]&&[$grade -le 69]
then
echo “You got a D”
elif [ $grade -ge 70 ]&&[$grade -le 79]
then
echo “You got a C”
elif [ $grade -ge 80 ]&&[$grade -le 89]
then
echo “You got a B”
elif [ $grade -ge 90 ]&&[$grade -le 100]
then
echo “You got an A”
else
echo"enter correct value"
fi
Aucun commentaire:
Enregistrer un commentaire