Answer
$y=3e^{-x}+1, x\leq 1$
and $y=3e^{-x}, x \gt 1$
Work Step by Step
We are given:
$y'+y=f(x)$
where
$f(x)=1,x \leq 1$ and $f(x)=0,x \gt 1$
Integrating factor:
$I(t)=e^{\int dx}=e^x$
Multiply both sides by the intergrating factor:
$e^xy'+e^xy=\frac{d}{dx}(ye^x)$
Integrate both sides:
$ye^x=\int e^x+c, x\leq 1$
and $ye^x=c, x \gt 1$
Since $y(0)=3$
$3e^0=c$
Solve for $c$:
$c=3$
Hence the particular solution are
$y=3e^{-x}+1, x\leq 1$
and $y=3e^{-x}, x \gt 1$