In a multidimensional infinite layer bounded by two hyperplanes, the inhomogeneous Helmholtz equation with a polynomial right-hand side is considered. It is shown that the Dirichlet and Dirichlet-Neumann boundaryvalue problems with polynomials in the right-hand sides of the boundary conditions have a solution that is a quasipolynomial that contains, in addition to the power functions, also hyperbolic or trigonometric functions. This solution is unique in the class of slow growth functions if the parameter of the equation is not an eigenvalue. An algorithm for constructing this solution is given and examples are considered.