New method for solving non-homogeneous periodic second-order difference equation and some applications