x=cats
2x=dogs
164x+24(2x)=4240
Distribute the 2x
164x+48x=4240
Combine like terms
212x=4240
Solve for x
x=20
So they can spend $20 on each cat and it says dogs are double that so the dogs are $40.
You can double check that by plugging it back in:
164(20)+24(40)=4240
3280+960=4240
4240=4240
Hope that helps.