You are asked to look for a function $\tilde{u}$ such that solving the
homogenous equation
$$ L (\tilde{u}) := \partial^2_{t t} \tilde{u} - \partial^2_{x x}
\tilde{u} = 0 $$
by separation of variables will yield a solution for the original
inhomogeneous equation
$$ L (u) = Ax. $$
So you want your function to fulfil
$$ \partial^2_{x x} \tilde{u} = \partial^2_{x x} u + A x. $$
Integrate this twice wrt. $x$ to obtain $\tilde{u}$, then solve the new equation and plug the result back. But careful with the new boundary conditions ($\tilde{u}$ has new values at the boundary). Good luck!