The 4221 code is a weighted code in which the four bit positions are assigned the weights (4221). The code is listed below.
$$
\begin{array}{ll}
0-0000 & 5-0111 \\
1-0001 & 6-1100 \\
2-0010 & 7-1101 \\
3-0011 & 8-1110 \\
4-1000 & 9-1111
\end{array}
$$
Design a BCD to 4221 code converter.