Hey Guys,
I am a newb when it comes to bash scripting,but I am loving the learning so far. I am at a wall though. I have scoured for hours tryng to find an answer.
Basically here is the pseudo code:
1. ask for users grade 3 times in using a loop.
2. Calculate the users number grade to a letter grade.
3. Print back average grade using the letter that corresponds.
Any ideas of how I can declare the users input as a unique variable each time and then store it until I calculate at the end?
This is what I have:
--------------------------------------------
#!/bin/bash
function LetterGrade ()
{
if [[ $GRD -gt "89" ]]
then
echo "A score of" $GRD "is an A"
else
if [[ $GRD -gt "79" ]]
then
echo "A score of" $GRD "is a B"
else
if [[ $GRD -gt "69" ]]
then
echo "A score of" $GRD "is a C"
else
if [[ $GRD -gt "59" ]]
then
echo "A score of" $GRD "is a D"
else
if [[ $GRD -lt "60" ]]
then
echo "A score of" $GRD "is an F"
fi
fi
fi
fi
fi
}
echo "Grade Application-Week 4 Indiv. Assignment"
for (( c=1; c<=3; c++))
do
read -p "Please insert Grade #$c:" GRD
LetterGrade $GRD
echo
done
Sum=`expr $GRD1 + $GRD2 + $GRD3 `
AvgGrd=`expr $Sum / 3 `
echo "Sum of all grades entered of: $GRD1, $GRD2, and $GRD3 is $Sum"
echo "Average of grades entered of: $GRD, $GRD, and $GRD is $AvgGrd"
LetterGrade $AvgGrd;
echo
-----------------------------------------------