Problem of first order differential equation. Let $y$ be the solution of 
$$y'+y=|x|, x \in  \mathbb R , y(-1)=0$$
Then $y(1)$ is equal to
1) $\frac{2}{e}-\frac{2}{e^2}$
2) $\frac{2}{e}- {2}e^2$
3) $2-\frac{2}{e^2}$
4) $2-2e$
Now i solve it by method $\frac{dy}{dx}+Py=Q$ by finding Integrating factor
$e^x$ and then solution is given by $ye^x=\int e^x|x|dx$+c
Now further since x is in $\mathbb R$ so i make two separate cases one when $x\gt 0$ and other for $x\lt 0$, but the problem is now for $x\gt 0$ i am unable to find out the constant value. Is this correct way to deal this problem? 
 A: $$y'(x)+y(x)=|x|\Longleftrightarrow$$

Let $r(x)=\exp\left[\int1\space\text{d}x\right]=e^x$.
Multiply both sides by $r(x)$:

$$e^xy'(x)+e^xy(x)=e^x|x|\Longleftrightarrow$$

Substitute $e^x=\frac{\text{d}}{\text{d}x}\left(e^x\right)$:

$$e^xy'(x)+\frac{\text{d}}{\text{d}x}\left(e^x\right)\cdot y(x)=e^x|x|\Longleftrightarrow$$

Apply the reverse product rule to the left-hand side:

$$\frac{\text{d}}{\text{d}x}\left(e^xy(x)\right)=e^x|x|\Longleftrightarrow$$
$$\int\frac{\text{d}}{\text{d}x}\left(e^xy(x)\right)\space\text{d}x=\int e^x|x|\space\text{d}x\Longleftrightarrow$$
$$e^xy(x)=\int e^x|x|\space\text{d}x\Longleftrightarrow$$

When $x\in\mathbb{R}$:

$$e^xy(x)=\left(e^x(x-1)+1\right)\text{sgn}(x)+1+\text{C}\Longleftrightarrow$$
$$y(x)=\frac{\left(e^x(x-1)+1\right)\text{sgn}(x)+1+\text{C}}{e^x}$$
Now, when $y(-1)=0$, we can solve $\text{C}$:
$$0=\frac{\left(e^{-1}((-1)-1)+1\right)\text{sgn}(-1)+1+\text{C}}{e^{-1}}\Longleftrightarrow$$
$$0=\frac{\left(e^{-1}(-2)+1\right)\left(-1\right)+1+\text{C}}{e^{-1}}\Longleftrightarrow$$
$$0=\frac{\left(1-\frac{2}{e}\right)\left(-1\right)+1+\text{C}}{e^{-1}}\Longleftrightarrow$$
$$0=\frac{\frac{2}{e}+\text{C}}{e^{-1}}\Longleftrightarrow$$
$$0=2+e\text{C}\Longleftrightarrow$$
$$-2=e\text{C}\Longleftrightarrow$$
$$\text{C}=-\frac{2}{e}$$
So:
$$y(x)=\frac{\left(e^x(x-1)+1\right)\text{sgn}(x)+1-\frac{2}{e}}{e^x}$$
And now we can find $y(1)$:
$$y(1)=\frac{\left(e^1(1-1)+1\right)\text{sgn}(1)+1-\frac{2}{e}}{e}=\frac{1+1-\frac{2}{e}}{e}=\frac{1+1-\frac{2}{e}}{e}=\frac{2-\frac{2}{e}}{e}$$
