I'm just wondering what's the formula to get the $x^2$ answers in this table:
$$\begin{align} \text{expected value}&=\frac{(\text{Total of the 1st Row})(\text{Total of the 2nd Column})}{\text{Overall Total}}\\ &=\frac{(90)(64)}{250}=23.04 \end{align}$$
Continue the computation until all the variables have expected values, compare them against the expected values below in the table, arrange for the computation of $x^2$.
$$\begin{array}{c|c|c|c|c} \text{observed}&\text{expected}&\text{observed}-\text{expected}&(\text{observed}-\text{expected})^2&x^2\\\hline 31&30.96&0.04&0&0\\ 2&20.64&-18.64&347.45&16.83\\ 53&34.4&18.6&345.96&10.06\\ 14&23.04&-10.36&107.33&6.99\\ 45&25.6&19.4&376.36&14.7\\ 45&36&9&81&2.25\\ 53&24&29&841&35.04\\ 2&40&-38&1444&36.1\\\hline &&&&125.52 \end{array}\\ x^2=125.52$$
The degree of freedom is calculated as $(\text{row}-1)(\text{column}-1)$, we have three number of rows and three number of columns hence $$\text{degree of freedom}=(\text{row}-1)(\text{column}-1)=(3-1)(3-1)=4$$
Refer to the table of the critical value for the chi square, the critical value in the table for $db=4$ and a significance of $0.05$ is $9.49$.
I get it now. Just divide the $(\text{observed}-\text{expected})^2$ value by the expected value. Example: $$\frac{347.45}{20.64} = 16.83$$