Piece-wise probability density and cumulative distribution function exercise Given a random variable $X$ with the density function:
$f(x) = a$ if $0 \leq x \leq b$      and 
$f(x) = b$ if $b < x < a + b$
I want to solve the following exercises regarding this distribution:
a) How large is $a$ if $b = 3a$?
b) $a = 0.5, b = 1$, then:
i) What is $P(X>1)$?
ii) What is $P(0.8<X<1.2)$
iii) What is $x_1$ s.t. $ P(X<x_1) = 0.05$?
c) Calculate $F(x)$
My ideas:
a) The area under the function has to sum up to $1$, hence I assume that $6a^2 = 1$ and hence $a = \sqrt{1/6}$ — is that correct?
b)
i) $[\frac{1}{2}x^2]_1^{1.5}$ 
ii) $ 0.5 * [\frac{1}{2}x^2]_{0.8}^{1} + [\frac{1}{2}x^2]_1^{1.2}$
iii) My idea would to solve for b in $\int_{0}^b f(x) x dx = 0.5 $ — but how exactly would I formulate $f(x)$?
c) I would assume we end up with two $F(x)$, each one being the integral of the respective $f(x)$ and hence $0.5x$ and $x$ respectively, is that correct?
Thanks

Hint: The cdf is
$$ F(x)=\begin{cases} 0, \  \text{if} \  x < 0  \\  \int_{0}^x 0.5 \, dt, \  \text{if} \ 0  \leq x \leq 1 \\  \int_{0}^1 0.5 \, dt+\int_1^{x} 1 \, dt, \  \text{if} \ 1 < x < 1.5 \\ 1, \  \text{if} \  x \geq 1.5\end{cases}$$ 
$$\Rightarrow F(x)=\begin{cases} 0, \  \text{if} \  x < 0  \\  0.5x, \  \text{if} \ 0  \leq x \leq 1 \\  x-0.5, \  \text{if} \ 1 < x < 1.5 \\ 1, \  \text{if} \  x \geq 1.5\end{cases}$$
$\int_{0}^1 0.5 \, dt=0.5t\bigg|_0^1=0.5-0=0.5$ 
$\int_1^{x} 1 \, dt=t\bigg|_1^x=x-1$
$0.5+(x-1)=x+0.5-1=x-0.5$
ad iii)
You know that $P(X\leq 1)=0.5$. Thus $x_1$ has to be in the interval $[0,1]$
$P(X <x_1)=0.5x_1=0.05 \Rightarrow x_1=\frac{0.05}{0.5}=0.1$
