First, you need to figure out hoe many boys and girls there are.
40% = 0.4
0.4 x 20 = 8 boys
20 - 8 = 12 girls
25% of the boys have glasses
0.25 x 8 = 2 boys who wear glasses
50% of the girls have glasses
0.5 x 12 = 6 girls who wear glasses
2 + 6 = 8
8 students wear glasses