Let f and b be the cost of foil and batteries respectively. We are first given that:
2f+3b=21 subtract 3b from both sides
2f=21-3b divide both sides by 2
f=(21-3b)/2
Then we are given:
5f+2b=25, using f found above in this equation gives you:
5(21-3b)/2+2b=25
(5(21-3b)+4b)/2=25 multiply both sides by 2
5(21-3b)+4b=50 carry out indicated operations on left side
105-15b+4b=50 combine like terms on left side
105-11b=50 subtract 105 from both sides
-11b=-55 divide both sides by -11
b=5, since f=(21-3b)/2
f=(21-3*5)/2
f=3
So batteries cost $5 and foil cost $3.