To find the mean, use the formula:
\[
\text{Mean} = \frac{\sum (f \cdot x)}{\sum f}
\]
where \( f \) is the frequency and \( x \) is the midpoint of the class.
The midpoints for each class are:
\[
5, 15, 25, 35, 45
\]
The mean is given as 22, so:
\[
\frac{12 \times 5 + 16 \times 15 + 6 \times 25 + x \times 35 + 9 \times 45}{12 + 16 + 6 + x + 9} = 22
\]
Now, solve for \( x \):
\[
\frac{60 + 240 + 150 + 35x + 405}{43 + x} = 22
\]
\[
\frac{855 + 35x}{43 + x} = 22
\]
Multiply both sides by \( 43 + x \):
\[
855 + 35x = 22(43 + x)
\]
\[
855 + 35x = 946 + 22x
\]
\[
35x - 22x = 946 - 855
\]
\[
13x = 91 \quad \Rightarrow \quad x = 7
\]
Hence, the value of \( x \) is 5.