Artificial intelligent assistant

Compute the expected value of the surplus water. > Water flows in and out of a dam such that the daily inflow is uniform on $[0, 2]$ (liters) and the daily outflow is uniform on $[0, 1]$, independently of the inflow. Each day the surplus water (if there is any) is collected for an irrigation project. Compute the expected amount of surplus water in a given day. Let $X=$ inflow and $Y=$outflow. Then $X\sim \text{unif}[0,2]$ and $Y\sim \text{unif}[0,1]$ and we denote the surplus as $g(X,Y)=Z=X-Y.$ By independence, it follows that $f(x,y)=f_X(x)f_Y(y)=1\cdot1/2=1/2.$ The range of $Z$ is $[0,2]$, since on a given day one can have zero outflow and 2 inflow or zero inflow and zero outflow. The formula for the expected value of $g(X,Y)$ is $$E(g(X,Y))=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}g(x,y)f(x,y) \ dxdy \tag{1}$$ But how do I determine the bounds for this doubleintegral?

We should have $g(X,Y)=Z=\max(0,X-Y).$

Note that $0 \le x \le 2$ and $0 \le y \le 1$.

\begin{align}E(g(X,Y))&= \int_0^1\int_0^2 g(x,y) f(x,y) \,\, dxdy \\\ &=\int_0^1\int_y^2 (x-y) f(x,y)\,\, dxdy\end{align}

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy e4bd1666b5b954f32d4be97ff35e96ce