100w+300h=8400
h+w=40, h=40-w, using this h in the first equation gives you:
100w+300(40-w)=8400 perform the indicated multiplication on left side
100w+12000-300w=8400 combine like terms on the left side
-200w+12000=8400 subtract 12000 from both sides
-200w=-3600 divide both sides by -200
w=18, and since h=40-w
h=40-18=22
So Howard ordered 18 boxes of wrenches and 22 boxes of hammers.