- #!/bin/bash
- echo "Enter the first mark: "
- read mark1
- echo "Enter the second mark: "
- read mark2
- echo "Enter the third mark: "
- read mark3
- total=$(echo "$mark1 + $mark2 + $mark3" | bc)
- avg=$(echo "scale=2; ($mark1 + $mark2 + $mark3) / 3" | bc)
- if (( $(echo "$avg >= 90 && $avg <= 100" | bc -l) )); then
- grade="A"
- elif (( $(echo "$avg >= 80 && $avg < 90" | bc -l) )); then
- grade="B"
- elif (( $(echo "$avg >= 70 && $avg < 80" | bc -l) )); then
- grade="C"
- elif (( $(echo "$avg >= 60 && $avg < 70" | bc -l) )); then
- grade="D"
- else
- grade="F"
- fi
- echo "Grand total of m1,m2,m3 out of 300 = $total"
- echo "The percentage = $avg"
- echo "The grade = $grade"