Answer
$y = -x~cos~x-x$
Work Step by Step
A first-order linear differential equation is one that can be put into the form:
$\frac{dy}{dx} + P(x)~y = Q(x)$
We can consider the given equation:
$xy' = y + x^2~sin~x$
$y' - \frac{y}{x} = x~sin~x$
Let $P(x) = -\frac{1}{x}$
Let $Q(x) = x~sin~x$
We can find the integrating factor:
$I(x) = e^{\int -\frac{1}{x} ~dx} = e^{-ln~x} = e^{ln~x^{-1}} = \frac{1}{x}$
We can multiply by the integrating factor:
$\frac{1}{x}y'-\frac{y}{x^2} = sin~x$
$\frac{d}{dx}(\frac{y}{x}) = sin~x$
We can integrate both sides of the equation:
$\frac{y}{x} = \int sin~x~dx$
$\frac{y}{x} = -cos~x+C$
$y = -x~cos~x+C~x$
We can use the initial condition to find $C$:
$y(\pi) = 0$
$-\pi~cos~\pi+C~\pi = 0$
$-\pi~(-1)+C~\pi = 0$
$\pi+C~\pi = 0$
$C~\pi = -\pi$
$C = -1$
We can write the solution:
$y = -x~cos~x-x$