Let $\mathbf F=xy\hat i+x^2\hat{j}+2\hat k$,$\hspace{.5cm}$ S is the closed surface bounded by the cone $z=\sqrt{x^2+y^2}$ and the plane $z=4$. Evaluate the surface integral $\displaystyle\int_S \mathbf{F\cdot n}\ \mathrm{d}S$ by Divergence Theorem.
$\nabla \cdot\mathbf F=y$
$$\begin{align} \int_S \mathbf{F\cdot n}\ \mathrm{d}S&=\int_0^2 \int_0^{2\pi} \int_0^4 (r\sin\theta)r\ \mathrm{d}z\ \mathrm{d}\theta\ \mathrm{d}r\\ \end{align}$$
However, $$\begin{align} \int_0^{2\pi}\sin\theta\ \mathrm{d}\theta&=0\\ \end{align}$$
so answer = $0$
But answer should be 4$\pi$
So I tried another method,
$$\mathbf{r}_x=(1,0,1)$$
$$\mathbf{r}_y=(0,1,1)$$
$$\therefore \mathbf{n}=(-1,-1,1)$$
$$\text{As we need inward, so}, \mathbf{n}=(1,1,-1)$$
$$\begin{align}
\iint_{S_1} \mathbf{F}\ \mathrm{d}\mathbf{S}&=\iint_{D}2\ \mathrm{d}A\\
&=2\cdot4\pi\\
&=8\pi
\end{align}$$
$$(xy,x^2,2)\cdot(1,1,-1)=xy+x^2-2$$
$$\begin{align}
\iint_{S_2} \mathbf{F}\ \mathrm{d}\mathbf{S}&=\int_{0}^{2\pi}\int_{0}^{2}(r^2\sin\theta\cos\theta+r^2\cos\theta-2)r\ \mathrm{d}r\ \mathrm{d}\theta\\
&=-4\pi\\
\end{align}$$
$\therefore \int_S \mathbf{F}\ \mathrm{d}\mathbf{S}=8\pi+(-4\pi)=4\pi$
Where did I make a mistake?
Given the vector field $\mathbf{F} : \mathbb{R}^3 \to \mathbb{R}^3$ of law:
$$ \mathbf{F}(x,y,z) = \left(x\,y,\,x^2,\,2\right) $$
and given the solid:
$$ \Omega = \left\{(x,y,z) \in \mathbb{R}^3 : \sqrt{x^2+y^2} \le z \le 4\right\} $$
by the divergence theorem, the flux of $\mathbf{F}$ out from $\partial\Omega$ is:
$$ \Phi_{\partial\Omega}(\mathbf{F}) = \iiint\limits_{\Omega} \nabla\cdot\mathbf{F}\,\text{d}x\,\text{d}y\,\text{d}z = \int_0^{2\pi} \text{d}\theta \int_0^4 \text{d}\rho \int_{\rho}^4 \rho^2\sin\theta\,\text{d}z = \color{red}{0}\,. $$
On the other hand, since the boundary $\partial\Omega$ is the union of two surfaces:
$$ \begin{aligned} & \mathbf{r}_1 = (\rho\cos\theta,\,\rho\sin\theta,\,\rho) \quad \quad \text{with} \; (\rho,\,\theta) \in D_1 := [0,4] \times [0,2\pi)\,; \\ & \mathbf{r}_2 = (\rho\cos\theta,\,\rho\sin\theta,\,4) \quad \quad \text{with} \; (\rho,\,\theta) \in D_2 := [0,4] \times [0,2\pi)\,; \end{aligned} $$
whose normal vectors to $\partial\Omega$ out from $\Omega$ are:
$$ \begin{aligned} & \mathbf{n}_1 = \mathbf{r}_{1,\theta} \land \mathbf{r}_{1,\rho} = \left(\rho\cos\theta,\,\rho\sin\theta,\,-\rho\right); \\ & \mathbf{n}_2 = \mathbf{r}_{2,\rho} \land \mathbf{r}_{2,\theta} = \left(0,\,0,\,+\rho\right); \end{aligned} $$
by definition, the flux of $\mathbf{F}$ out from $\partial\Omega$ is:
$$ \begin{aligned} \Phi_{\partial\Omega}(\mathbf{F}) & = \iint\limits_{D_1} \mathbf{F}(\mathbf{r}_1) \cdot \mathbf{n}_1\,\text{d}\rho\,\text{d}\theta + \iint\limits_{D_2} \mathbf{F}(\mathbf{r}_2) \cdot \mathbf{n}_2\,\text{d}\rho\,\text{d}\theta \\ & = \int_0^{2\pi} \text{d}\theta \int_0^4 \left(-2\rho+2\rho^3\sin\theta\cos^2\theta\right)\text{d}\rho + \int_0^{2\pi} \text{d}\theta \int_0^4 2\,\rho\,\text{d}\rho \\ & = -32\pi + 32\pi \\ & = \color{red}{0}\,. \end{aligned} $$
If the exercise is reported correctly and the book writes $4\pi$ as the result, it's a mistake.