You've definitely dun-goofed here.
Imagine you're still holding the money, and dont give it back to your friends.
30$ in your hands = 10$ each
He takes 5$ off the price of the boat trip = 25$ but wants a 2$ tip = new cost of 27$
27/3 = 9$ per person
Why are you suddenly giving the captain another 2$ tip?
Regardless, the damn dollar is in your hand where its always been.