Hi,
Let x represent number of dimes. then (40-x) would be the number of nickels.
5(40-x) + 10x = 240 cents
200 - 5x + 10x = 240
5x = 40
x = 8, the number of dimes. Number of nickels would be 32 (40-8)
checking our answer
5*32 + 10*8 = 160 + 80 = 240 cents