Let V =the volume of the tank
The first pipe fills 1/5 of the tank per hour: Rate 1 = +V/5
The second pipe empties 1/8 of the tank per hour: Rate 2 = -V/8
Rate 1 is positive because it's filling the tank. Rate 2 is negative because it's emptying the tank. We leave each pipe open for a time t, and we want the tank to be full (volume = V) at the end of that time.
(Rate 1)*time + (Rate 2)*time = full tank (V)
(V/5)t + (-V/8)t = V
(1/5 - 1/8)Vt = V (Factor out V and t)
(3/40)t = 1 (Subtract the fractions, divide both sides by V)
t = 40/3 = 13 1/3 hours (13 hours 20 minutes)
Check:
(V/5)(40/3) + (-V/8)(40/3) = (8/3)V - (5/3)V = (3/3)V = V It fills the tank!

Philip P.
04/10/14