Problem 1:
http://www.math.toronto.edu/courses/apm346h1/20159/PDE-textbook/Chapter2/S2.6.P.html#problem-2.6.1(a) Here we have a
Dirichlet boundary condition. In the domain ${t>0, x \geqslant ct}$, the solution is given by the D'Alembert formula:
\begin{equation}
u(x,t) = \frac{1}{2}[g(x+ct) + g(x-ct)] + \frac{1}{2c} \int_{x-ct}^{x+ct} h(y)dy
\end{equation}
So plugging in the initial conditions as specified in the problem, we arrive at the solution:
\begin{equation}
u(x,t) = \phi(x+ct)
\end{equation}
In the domain ${0<x<ct}$, the solution is given by:
\begin{equation}
u(x,t) = \frac{1}{2}g(x+ct) + \frac{1}{2c} \int_{0}^{x+ct} h(y)dy + p\bigg(t - \frac{x}{c}\bigg) - \frac{1}{2}g(ct-x) - \frac{1}{2c} \int_0^{ct-x} h(y)dy
\end{equation}
So plugging in the initial and boundary conditions as specified in the problem, we arrive at the solution:
\begin{equation}
u(x,t) = \phi (x+ct) + \chi\bigg(t-\frac{x}{c}\bigg) - \phi(ct-x)
\end{equation}
So the solution to (a) is
\begin{equation}
u(x,t) =
\begin{cases}
\phi(x+ct) & \text{for } \{t>0, x \geqslant ct\}\\
\phi (x+ct) + \chi\bigg(t-\frac{x}{c}\bigg) - \phi(ct-x) & \text{for } \{0<x<ct\}
\end{cases}
\end{equation}
(b) In this case we have a
Neumann boundary condition. The solution for the domain ${t>0, x \geqslant ct}$ is the same as in part (a), namely:
\begin{equation}
u(x,t) = \phi(x+ct)
\end{equation}
For the domain ${0<x<ct}$, the solution is given by:
\begin{equation}
u(x,t) = \frac{1}{2}g(x+ct) + \frac{1}{2c} \int_0^{x+ct} h(y)dy - c \int_0^{t-\frac{x}{c}} q(t')dt' + \frac{1}{2}g(ct-x) + \frac{1}{2c} \int_0^{ct-x} h(y)dy
\end{equation}
Plugging in our initial and boundary conditions as specified in the problem, we arrive at the solution:
\begin{equation}
u(x,t) = \phi (x+ct) - \phi (0) - cX\bigg(t-\frac{x}{c}\bigg) + cX(0) + \phi(ct-x)
\end{equation}
where
\begin{equation}
\int\chi(t')dt' = X(t')
\end{equation}
So the solution to (b) is
\begin{equation}
u(x,t) =
\begin{cases}
\phi(x+ct) & \text{for } \{t>0, x \geqslant ct\}\\
\phi (x+ct) - \phi (0) - cX\bigg(t-\frac{x}{c}\bigg) + cX(0) + \phi(ct-x) & \text{for } \{0<x<ct\}
\end{cases}
\end{equation}