To solve the problem, we will use the profit function given:
\[ P(x) = 20x - 6000 \]
Part 1: Find the number of hats for a profit of $8000
We set the profit function equal to $8000 and solve for \( x \):
\[ 8000 = 20x - 6000 \]
First, add 6000 to both sides:
\[ 8000 + 6000 = 20x \]
\[ 14000 = 20x \]
Next, divide by 20:
\[ x = \frac{14000}{20} = 700 \]
Answer for Part 1: Producing and selling 700 hats will give a profit of $8000.
Part 2: Find the number of hats to avoid a loss
To avoid a loss, the profit must be at least $0. We set the profit function to be greater than or equal to $0:
\[ 0 \leq 20x - 6000 \]
Add 6000 to both sides:
\[ 6000 \leq 20x \]
Next, divide by 20:
\[ x \geq \frac{6000}{20} = 300 \]
Answer for Part 2: To avoid a loss, 300 hats must be produced and sold.