A trader buys some bags of wheat from a farmer at a rate of $20 per bag. If it costs $2 to transport each bag from the farm to the warehouse, and the trader made a total profit of $400 after selling all the bags at a rate of $30 each, how many bags did he sell?
Each bag of wheat cost the trader $20+$2=$
<gadget id="calculator">20+2</gadget>
<output>22</output>
22 (taking transportation costs into account)
Each bag of wheat was sold for $30 each giving a profit of $30-$22=$
<gadget id="calculator">30-22</gadget>
<output>8</output>
8 on each bag.
Since a total of $400 profit was made, the total number of bags sold is $400/$8=
<gadget id="calculator">400/8</gadget>
<output>50</output>
50 bags.

<result>50</result>