Number of boys in the gym class = 12
Number of girls in the gym class = 10
then
Ratio of boys to ratio of girls = 12:10
= 6:5
Now
Number of boys joining the gym class later = 6
So after the new boys join the number of boys in the gym class becomes = 18
The ratio of boys to girls have to remain the same
Let us assume that the number of girls that need to join the gym class = x
Then
6/5 = 18/(x + 10)
6(x + 10) = 18 * 5
6x + 60 = 90
6x = 90 - 60
6x = 30
x = 30/6
= 5
So the number of girls that need to join the gym class to keep the ratio same is 5. I hope the procedure is clear enough for you to understand.