Hi again everyone.
I'm getting better at bash shell script, but I'm still a beginner, so I have another question.
I'm trying to prompt the user to enter their grades so I can run these two functions that will average the grades and give them a letter grade. This is currently the code I have right now:
Code:
#!/bin/bash
#First, define calcAverage
calcAverage() {
sum=0
for score in "$1"
do
sum=$((sum + score))
done
average=$((sum /$#))
echo "$average"
}
#Then, define determineGrade
determineGrade() {
score=$1
if (( score >= 90 && score <= 100)); then
grade="A"
elif (( score >= 80 && score <= 89)); then
grade="B"
elif (( score >= 70 && score <= 79)); then
grade="C"
elif (( score >= 60 && score <= 69)); then
grade="D"
else
grade="F"
fi
echo "$grade"
}
To be specific, I'm trying to get the user to input five grades to average. I'm not really sure where to go from here, though... I know how to ask for a user input, but while calling the functions? I'm confused, especially because the prompt in general confused me.
So I'm asking, where do I go from here? How do I call the functions while using the user's input?