The boat's speed is B. Distance=speed*time. Speed=distance/time, so time=distance/speed.
Speed is variable because upstream, against the current, the combined speed of the boat and the current is B-3 while with the current it's B+3. We can equate distance/speed for upstream and downstream: 6/(B-3)=9/(B+3).
6(B+3)=9(B-3); 6B+18=9B-27; 3B=45, so B=15mph, the speed of the boat.
CHECK
The actual speed downstream is 18mph so in one hour the distance would be 18 miles. In half an hour it would be 9 miles. The overall time then is one hour to travel upstream and downstream.
The actual speed upstream is 12mph. So in one hour the distance would be 12 miles. In half an hour it would 6 miles.
COROLLARY
Assuming, as we did, that the time to travel 6 miles upstream after travelling 9 miles downstream all in one hour, means that the two journeys each took a half-hour, then 6/(B-3)=1/2, or 12=B-3, so B=15mph would have been sufficient to work out the boat's speed in still water. Similarly, 9/(B+3)=1/2, or 18=B+3, making B=15mph.