Water hammer is the unsteady flow in conduits due to sudden change of velocities in pipelines and poses it to danger. Sensitivity analysis is performed to show the effect of pump and pipeline parameters on the maximum and minimum head just downstream the pump after pump power failure. A new approach to find the required gas volume in a hydropneumatic tank (air vessel) to protect the pipeline using artificial neural networks (ANNs) is introduced. About 760 runs were generated using Bentley Hammer v8i. For each run, the maximum and minimum head just downstream the pump were calculated for a pump power failure. Two MATLAB codes are written to use networks for finding the best design that guarantees the pressure in the pipeline is within the allowable range. The results showed that pump inertia and wave celerity have a very small effect on the maximum and minimum heads.