Two angles are complementary if their measures add up to 90 degrees. We know one angle measures 40 degrees and the other measures \(8x + 2\) degrees.
We can set up the equation:
\[ 40 + (8x + 2) = 90 \]
Now, combine like terms:
\[ 40 + 8x + 2 = 90 \]
\[ 8x + 42 = 90 \]
Next, isolate \(8x\) by subtracting 42 from both sides:
\[ 8x = 90 - 42 \]
\[ 8x = 48 \]
Now, divide by 8 to solve for \(x\):
\[ x = \frac{48}{8} \]
\[ x = 6 \]
Thus, the value of \(x\) is \(6\).