Final answer:
Each hat was sold for $12 and each shirt for $-2.
Step-by-step explanation:
To find the price of each hat, we'll solve a system of equations using the given information.
Let's denote the price of a hat as 'h' and the price of a shirt as 's'.
From the first equation, we know that 5h + 3s = 45. From the second equation, we know that 2h + 6s = 42.
To solve this system of equations, we can use substitution or elimination. Here, we'll use substitution.
From the second equation, we can rewrite it as h = (42 - 6s) / 2.
Substituting h in the first equation, we get 5((42 - 6s) / 2) + 3s = 45.
Simplifying this equation, we get: 21 - 15s + 3s = 45. Combining like terms, we have -12s = 24. Dividing by -12, we get s = -2.
Substituting s = -2 back into the equation h = (42 - 6s) / 2, we get h = (42 - 6(-2)) / 2. Simplifying this equation, we have h = 12.
Therefore, Barney sold each hat for $12 and each shirt for $-2.