time = distance/speed
Let b represent the speed of the boat in miles per hour. Then the speed upstream is b-3, and the speed downstream is b+3. The total time is
4 = 20/(b-3) + 8/(b+3)
4(b-3)(b+3) = 20(b+3) +8(b-3) . . . multiply by the product of the denominators
4(b^2 -9) = 28b +36
4b^2 -28b -72 = 0
4(b-9)(b+2) = 0
b = 9 or -2 . . . . . -2 is an extraneous solution
The speed of the boat in still water is 9 mph.