The total amount of money James has is 3a + 2b + 2 = 2a + 3b + 6
Set these equations equal
3a + 2b + 2 = 2a + 3b + 6 rearrange as
a - b = 4
a = 4 + b
If Judith arrives with the same amount of money as James....then twice their money = 6 items each
2 ( 3a + 2b + 2) = 6a + 6b simplify
6a + 4b + 4 = 6a + 6b subtract 6a from both sides
4b + 4 = 6b subtract 4b from both sides
4 = 2b divide both sids by 2
2 = b ⇒ the pencils cost $2
And the pens cost a = 4 + b = 4 + 2 = $6
So (a,b) = (6, 2)