If we call the cost C then Cecil has to mark the product up 40% of C. That means he needs to charge the whole cost (100%) + 40% of the cost.
That is 140% of C. This amount needs to be $20.
In an equation we have 140% of C which can be written

set equal to $20. We solve for C which is the cost or what Cecil should pay for a hat.


This is a proportion so we cross-multiply to solve:


C=$14.29