The random variable $X$ has a continuous probability density function $f(x)$ given by
$$
f(x)=
\begin{cases}
0, & x\leqslant1,\\
\ln x, & 1\leqslant x\leqslant k,\\
\ln k, & k\leqslant x\leqslant2k,\\
a-bx, & 2k\leqslant x\leqslant4k,\\
0, & x\geqslant4k,
\end{cases}
$$
where $k$, $a$ and $b$ are constants.
(i) Sketch the graph of $y=f(x)$.
(ii) Determine $a$ and $b$ in terms of $k$ and find the numerical values of $k$, $a$ and $b$.
(iii) Find the median value of $X$.