Answer
23 hats
Work Step by Step
Suppose $x$ is the number of hats sold and $y$ is the number of scarves sold.
Set up the equations.
$x+y= 42$ and $16x+18y =710$
We need to add $-16$ times in the first equation.
$-16x-16y= -672$ and $16x+18y =710$
This gives: $2y =38 \implies y=19$
Now, $x+19= 42$
This gives: $x=23$
Hence, $x=23$ hats and $y=19$ scarves.