Hello, thank you for taking the time to post your question!
The key on this type of question is to find a way to relate the variables algebraically. On this one we have
Downstream Rate: 18 miles / 2 hours = 9 mph
Upstream Rate: 18 miles / 4.5 hours = 4 mph
If you let B represent the boat’s speed and C represent the current speed, that means that our underlying equation here is
(B + C) + (B – C) = 9 + 4
Solving that for B algebraically yields
2B = 13
B = 6.5, meaning that the rate in still water is 6.5 mph
Then
(6.5 + C) = 9
C = 2.5, meaning that the rate of the current is 2.5 mph
I hope that helps you get moving in a better direction on this type of question! Feel free to reach out if you have any additional questions beyond that :)