Answer
$276$ grade-A tires, $553$ grade-B tires.
Work Step by Step
Step 1. Assuming the profit (per hundred tires) on a grade A tire is $p_A$ and that on a grade B tire is $p_B$, we have $p_A=2p_B$
Step 2. The total profit is given by $P=x\ p_A+y\ p_B=2x\ p_B+p_B\times\frac{40-10x}{5-x}=2p_B(x+\frac{20-5x}{5-x})=2p_B(x+\frac{25-5x-5}{5-x})=2p_B(x+5-\frac{5}{5-x})$
Step 3. We have $P'=2p_B(1-\frac{5}{(5-x)^2})$ and by letting $P'=0$, we have $(5-x)^2=5$ and as $0\leq x\leq 4$, we get $x=5-\sqrt 5\approx2.764$
Step 4. Check signs of $P'$ to get $(0)..(+)..(5-\sqrt 5)..(-)..(4)$; we can confirm that $x=\approx2.764$ gives the maximum profit.
Step 5. At $x=5-\sqrt 5\approx2.764$ or about $276$ grade-A tires; thus we have $y=\frac{40-10x}{5-x}=10-2\sqrt 5\approx5.528$ or about $553$ grade-B tires.