I can get you set up.
The key is to let x be the distance from A to B. Then the rest of the shore distance is 9-x.
The distance from B to the facility is the hypotenuse of the triangle.
Use Phy. Th. to get the underwater distance given by sqrt(x^2+16). Thus the cost of underwater pipe is 300,000*(sqrt(x^2+16)). The shore pipe cost is then simply 200,000*(9-x)
So total cost is: 300,000*(sqrt(x^2+16)) + 200,000(9-x) in dollars.
You need to take the derivative and set equal to zero to find the optimum point x. This requires some algebra and squaring both sides. This is the answer to part a).
The rest of the problem I leave to you.