In this paper the steady cavitating or non-cavitating flows around three-dimensional bodies (such as hydrofoils, struts, ships etc) inside a numerical towing tank (NTT) are addressed by an iterative boundary element method (IBEM). The iterative nonlinear method is based on the Green's theorem, which is applied to the surfaces of the cavitating or non-cavitating surface piercing body, to the the walls of NTT and to the free surface. The integral equation based on Green's theorem is divided into five parts: (i) The surface piercing body part, (ii) The free surface part, (iii) The right side wall of tank, (iv) The left side wall of tank and (v) The bottom wall of tank. These five problems are solved separately, with the effects of one on the others being accounted for in an iterative manner. The cavitating or non-cavitating three-dimensional surface piercing body is modeled with constant strength dipole and constant strength source panels, distributed over the body surface including the cavity surface. The free surface part and the side and the bottom walls of NTT are also modeled with constant strength dipole and source panels. All these parts of the problem are solved separately, with the effects of one on the others being accounted for in an iterative manner. For the validation of the method it is first applied to a Wigley hull Then, the method is applied to a cavitating rectangular hydrofoil and the effects of the reflected waves from walls of NTT on cavity characteristics are discussed.