The GPA is calculated as a weighted average of the grades, when the number of credit/hours is the weight and the numeric grade is taken from the GPA table.
The GPA is equal to the sum of the product of the credit hours weight (w) times the grade (g):
GPA = w1×g1+ w2×g2+ w3×g3 + ... + wn×gn
The credit hours weight (wi) is equal to the credit hours of the class divided by the sum of the credit hours of all the classes:
wi= ci / (c1+c2+c3+...+cn)