So lets say thatgirls = gandboys = b

At first it was that:g/(g+b) = 4/10

Which means that:g = (4g+4b)/10

You also know that:(g+5)/(g+b+5) = 5/10

Therefore:g+5 = (5g+5b+25)/10

Subtract:g = (5g+5b+25)/10 - 5

Which means:g = (5g+5b+25-50)/10 = (5g+5b-25)/10

Substitute:(4g+4b)/10 = (5g+5b-25)/10

Multiply both sides by 10 to get:4g+4b = 5g+5b-25

You can change that into:25 = g+b

Go back to this:g/(g+b) = 4/10

I hope you understand that:b/(g+b) = 6/10

Substitute:b/25 = 6/10

Multiply both sides by 25 to get:b = 150/10

Simplify:b = 15

So there are 15 boys in the class.