How to solve the given initial-value problem? Solve the given problem which the input function $g(x)$ is discontinuous?
$y''+4y = g(x)$, $y(0) = 1$, $y'(0) = 2$, where
$$g(x) = \begin{cases} \sin x, & 0\leq x\leq\frac{\pi}{2}\\
0,& x>\frac{\pi}{2} \end{cases}$$
And the given answer is,
$$y = \begin{cases} \cos 2x+\frac56\sin2x+\frac13\sin x, & 0\leq x\leq\frac{\pi}{2}\\
\frac23\cos 2x+\frac56\sin2x,& x>\frac{\pi}{2} \end{cases}$$

Note: It is best to use Laplace Transforms for these sorts of problems and this is where the LT shows it's usefulness, but that is not allowed, so we will use undetermined coefficients instead.
We are given:
$\tag 1 y''+4y = g(x), y(0) = 1, y'(0) = 2$
where
$$g(x) = \begin{cases} \sin x, & 0\leq x\leq\frac{\pi}{2}\\
0,& x>\frac{\pi}{2} \end{cases}$$
The approach will be as mentioned by D.F. in comments, we are going to solve for the lower interval and use that result to solve the upper interval (in essence, we are solving two ODEs). 
We start out by finding the homogeneous solution to $(1)$, so we have:
$$m^2 + 4 = 0 \rightarrow m_{1,2} = \pm 2i$$
This gives us:
$$y_h = c_1 \cos 2x + c_2 \sin 2x$$
Next, we will solve for the particular solution, so we guess at a solution of the form:
$$y_p = a \cos x + b \sin x$$
To solve for the constants, $a$ and $b$, we substitute back into $(1)$, yielding:
$-a \cos x - b \sin x + 4a \cos x + 4b \sin x = \sin  x$
This yields $a = 0$ and $b = \dfrac{1}{3}$.
So, we can write our solution as: $y = y_h + y_p = c_1 \cos 2x + c_2 \sin 2x + \dfrac{1}{3} \sin x$
Using the IC's, we solve for $c_1$ and $c_2$, yielding $c_1 = 1, c_2 = \dfrac{5}{6}$, so we have:
$$\tag 2 y(x) = \cos 2x + \dfrac{5}{6} \sin 2x + \dfrac{1}{3} \sin x, 0 \le x \le \dfrac{\pi}{2}$$
Next, we want to solve for the upper upper half of the range, so we have, $y'' + 4y = 0$, but we need ICs. We will use $(2)$ to generate an IC at $\dfrac{\pi}{2}$ (do you know what allows us to do this and why it is useful to do so?).
So, using $(2)$, we get $y\left(\dfrac{\pi}{2}\right) = -\dfrac{2}{3}$ and $y'\left(\dfrac{\pi}{2}\right) = -\dfrac{5}{3}$.
We have our solution for $(2)$ from earlier as: $y = c_1 \cos 2x + c_2 \sin 2x$
Using these new ICs, we arrive at, $c_1 = \dfrac{2}{3}, c_2 = \dfrac{5}{6}$, so:
$$\tag 3 y(x) = \dfrac{2}{3} \cos 2x + \dfrac{5}{6} \sin 2x, x \gt \dfrac{\pi}{2}$$
Using $(2)$ and $(3)$, the solution can be written as:
$$y(x) = \begin{cases} \cos 2x + \dfrac{5}{6} \sin 2x + \dfrac{1}{3} \sin x, & 0\leq x\leq\frac{\pi}{2}\\
\dfrac{2}{3} \cos 2x + \dfrac{5}{6} \sin 2x,& x>\frac{\pi}{2} \end{cases}$$
