Tank A contains 15 gallons of mixture, from what 5 gallons is alcohol,
that is 1/3
Tank B contains 15 gallons of mixture, from what 3 gallons is alcohol,
that is 1/5
According to this, tank A contains 100/3 % alcohol and tank B contains 20% alcohol.
Let's named variables:
gallons from tank A will be the x and from tank B will be the y
Equations are: x+y=8 and (100/3)x+20y= 8 * 25
From first we expressed x=8-y, than replace in the second
(100/3) ( 8-y) + 20y = 200 the whole equation multiply with 3 and get
100(8-y) + 60y = 600 => 800 -100y+60y=600 => 800-40y=600 =>
800-600=40y => 40y=200 => y=5
than we replace this result in
x= 8-5=3 => x=3
It will be taken from tank A- 3 gallons and from tank B- 5 gallons.
Good luck!!!