Let's define the following variables:
x: number of 3 hour courses
y: number of 4 hour courses
The statement, " He has earned a total of 59 credits after completing 18 courses" gives us our two equations:
3x + 4y = 59
x + y = 18
We can multiply everything in the second equation by - 3 to get the x-terms to have opposite coefficients:
3x + 4y = 59
-3x - 3y = 54
If we then add like-terms together, we get:
y = 5, so he has taken 5 four-hour courses.