What you need to know is that the 5 spoilt eggs are not sold, hence cannot earn any profit. However, the cost of the spoilt eggs must also be counted into the cost of the eggs.
Let x be the total eggs the grocer bought,
Revenue - Costs = Profit
(x - 5) RM0.45 - (x)RM0.35 = RM 10.25
(RM0.45x - RM2.25) - RM0.35x = RM10.25
RM0.45x - RM0.35x = RM10.25 + RM 2.25
RM0.10x = RM12.50
0.1x = 12.5
x = 12.5 ÷ 0.1
= 125 ÷ 1
= 125
∴ In conclusion, the grocer bought 125 eggs in total.