Compute $E(|X-Z|)$. Let $X$ be a random variable distributed uniformly on [0,20]. Define a new
random variable $Z$ by $Z= [X+.5 ]$  (the greatest integer in $X$). Find the expected
value of $Z$.  Compute $E(|X-Z|)$. 

Attempt: 
I attempted to set up the integral $$\int_{0}^{20}\frac 1 {20}\,dx,$$ since I found out that it was uniformly distributed on $[0,1]$. Also, I thought the distribution function would be $\dfrac 1 {20}$. Then, I used the formula $E(|X-Z|)=E(X)-E(Z)$, 
I found out that $E(X)=10$, after doing the calculation, then I took the integral $$\int_{0}^{20}(X^2+.5X)dx,$$ but was unable to find the right answer.
 A: First off, $E(|X-Z|) \ne E(X)-E(Z).$ We have $E(X-Z) = E(X)-E(Z)$ but that doesn't imply it for absolute value. Don't ever say or think that again.
Second, you seem to have mistakenly multiplied through by an extra factor of $x$ in the integral. This was probably motivated by the fact that you multiply the density $p(x)$ by $x$ and integrate to get the expected value of $x$. But $(X+.5)$ is not the density... it's the thing you're taking the expected value of... so you just need to put it in the integral, multiply by the density $(1/20$ in this case) and integrate.
So the expression you want is $$ E(|X-Z|) = E(|X-[X+.5]|) = \frac{1}{20}\int_0^{20} |x-[x+.5]|dx$$ 
Now it's a matter of figuring out what the expectation value is. For this I suggest figuring out what the integrand looks like. 
Assuming the brackets mean integer part, $[X+.5]$ is pretty much just $X$ rounded off to the nearest integer. Then $|X-[X+.5]|$ is the distance between $X$ and its closest integer. This can be as small as $0$ or as great as $.5$ and it moves up and down in an orderly manner as $X$ changes.
From this information, hopefully you can draw a plot of the integrand and figure out what its average value is. It should be relatively clear from the plot what the average value is, but you can also get it through doing the integral.
A: Humor my whim and write $X=1/2 + k +\theta$, where $k$ is an integer and $\theta\in[0,1)$. Then $[X+1/2] = k+1$ and $X-[X+1/2] = \theta-1/2$. Now observe that the value of $X-[X+1/2]$ depends only on the fractional part of $X+1/2$.  When $X$ ranges uniformly over $[0,20]$, the quantity $\theta$ ranges uniformly on $[0,1]$ and $X-[X+1/2]$ ranges uniformly over $[-1/2,1/2]$. Can you finish from there?
