Answer
When $\phi = 0$, situations (a) and (e) can occur when $t = 0$
When $\phi = \frac{\pi}{2}$, situations (c) and (g) can occur when $t = 0$
Work Step by Step
We can restate Equation (31-12):
$q = Q~cos~(\omega t+\phi)$
In situations (a) and (e), the capacitor is fully charged, so $cos~(\omega t+\phi) = 1$
We can find $\phi$:
$cos~(\omega t+\phi) = 1$
$\omega t+\phi = 0$
$(\omega)(0)+\phi = 0$
$\phi = 0$
In situations (c) and (g), the capacitor has no charge, so $cos~(\omega t+\phi) = 0$
We can find $\phi$:
$cos~(\omega t+\phi) = 0$
$\omega t+\phi = \frac{\pi}{2}$
$(\omega)(0)+\phi = \frac{\pi}{2}$
$\phi = \frac{\pi}{2}$