**Answer:**

The answer is below

**Step-by-step explanation:**

Let x represent the number of small hat purchased, y represent the number of medium hat purchased and z represent the number of large hat purchased.

Since a total of 47 hats where purchased, hence:

x + y + z = 47 (1)

Also, he spent a total of $302, hence:

5.5x + 6y + 7z = 302 (2)

He purchases three times as many medium hats as small hats, hence:

y = 3x

-x + 3y = 0 (3)

Represent equations 1, 2 and 3 in matrix form gives:

Therefore he purchases 6 small hats, 18 medium hats and 23 large hats