Here the GPA is the weighted average of the four grades in the four courses, i.e., 4.0, 2.4, 2.9, and 3.0. The weights are the number of credits in the four courses, i.e., 5, 2, 5, and 4.
So the GPA is
(5 * 4.0 + 2 * 2.4 + 5 * 2.9 + 4 * 3.0) / (5 + 2 + 5 + 4)
≈ 3.21