b = 3g (There are three times as many boys as girl)
b = g + 24 (there are 24 more boys than girls)
Since both equations equal b, they also equal one another:
3g = g + 24
Subtract g from both sides:
2g = 24
Divide both sides by 2:
g = 12
b = 3 * 12
b = 36
There are 36 boys in the class