find the continuous solution of $\displaystyle \frac{dy}{dx}+y=g(x), 0<x<\infty, y(0)=2$ where $\displaystyle g(x)=3, 0<x<\frac{\pi}{2}$

$\displaystyle =\cos x, x\geq\frac{\pi}{2}$

for the first part, i got $\displaystyle -ln(3-y)=x$. but how can i solve it for the second part?