Question: Calculating Your GPA (BASH script) For this script we are going to build a small tool that will take in an x number of grade
Calculating Your GPA (BASH script)
For this script we are going to build a small tool that will take in an x number of grade points and at the end spit out our average grade points and grade letter. For this script you will need
Name This Script: myGPA
To use a while loop since this loop will run for an x amount of time
Continues to prompt the user to enter their grade points
Stops prompting a user when the user enters 99. Use a break to exit the loop
DO NOT INCLUDE THE NUMBER 99 IN YOUR CALCULATIONS
Use the bc command since we are dealing with decimals
At the end spit out the average GPA along with the Grade Letter.
Equation: Add Up All The Numbers and then divide by the total numbers inputted (IGNORE THE NUMBER 99)
Use this chart to determine which grade letter to show
To compare floating point types (real numbers): while (( $(echo "$grade != 99" | bc ) ))
To add F.P. Type: sum=$(echo "scale=2;($sum+$grade)" | bc)
| Grade Points | Grade Letter |
| 4.00 and up | A |
| 3.00 - 3.99 | B |
| 2.00 - 2.99 | C |
| 1.00 - 1.99 | D |
| 0.99 and below | F |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
