a) For $x>3t$ the solution is given by D'Alembert's formula: $$u(x,t)=\frac{1}{6}[\sin(x+3t)-\sin(x-3t)]=\frac{1}{3}\cos(x)\sin(3t)$$
Here we have Dirichlet boundary condition. We use
http://www.math.toronto.edu/courses/apm346h1/20159/PDE-textbook/Chapter2/S2.6.html#mjx-eqn-eq-2.6.31. Then for $0<x\leq3t$:$$u(x,t)=\frac{1}{6}[\sin(x+3t)-\sin(3t-x)]=\frac{1}{3}\cos(3t)\sin(x)$$
b) For $x>3t$ the solution is the same as in part a)
Here we have Neumann boundary condition. We use
http://www.math.toronto.edu/courses/apm346h1/20159/PDE-textbook/Chapter2/S2.6.html#mjx-eqn-eq-2.6.31-. Then for $0<x\leq3t$:$$u(x,t)=\frac{1}{6}[\sin(x+3t)+\sin(3t-x)]=\frac{1}{3}\cos(x)\sin(3t)$$
c) For $x>3t$: $$u(x,t)=\frac{1}{6}[-\cos(x+3t)+\cos(x-3t)]=-\frac{1}{3}\sin(x)\sin(-3t)=\frac{1}{3}\sin(x)\sin(3t)$$
Dirichlet boundary condition. For $0<x\leq3t$:$$u(x,t)=\frac{1}{6}[-\cos(x+3t)+\cos(3t-x)]=\frac{1}{3}\sin(x)\sin(3t)$$
d) For $x>3t$ the solution is the same as in part c)
Neumann boundary condition. For $0<x\leq3t$:$$u(x,t)=\frac{1}{6}[-\cos(3t-x)+1+-\cos(x+3t)+1]=-\frac{1}{6}[\cos(3t-x)+\cos(x+3t)-2]=-\frac{1}{3}[\cos(3t)\cos(x)-1]$$