Grades Exercise
Objective
To get experience dealing with C programs split into multiple files.Task
For this lab, you should make a .h and .c file pair for working with calculating course
grades. First make a struct called Course which has the following fields:
- Letter grade, which is an array of chars of size 3
- Credits, which is an integer
Then make two functions:
double grade_points(char grade[3])double calculate_gpa(Course* courses, int num)
The first of these should return the quality points that correspond to a letter grade. You can find this information in a table on the Grading and Your GPA page of the UMW website.
The second function takes an array of course objects and returns the GPA of a student who completed
that set of courses. To calculate this, we add the students total quality points, which is the sum
of each course's quality points multiplied by the number of credits. This total is then divided
by their total number of credits. This function should call grade_points on each grade.
Remember to declare the functions in the .h file and define them in the .c file.
Don't forget to put an include guard in the header file.
To complete this program, you can download the main.c file which
calls calculate_gpa on some example data. When you are done you should get
the following output:
Overall GPA = 3.55
Submitting
When you are done, please submit the .c and .h files under the assignment in Canvas.