Eiffel "Gotchas"


Gotcha #10 - discounts

A business offers a discount to certain customers. On some products, the discount is 10% of the gross price; on other products the discount is 15% of the net price.

There is a "discount" column on the invoices, in which the discount is printed by this code:

   if discount_type.is_equal("gross") then
      print("10%GROSS")
   else
      print("15%NET  ")
   end
Despite the use of a monospace font and the two extra spaces after "NET", the invoice layout is messed up and the preprinted stationery is wasted every time a customer purchases a product with a "net" discount. Why?

ANSWER


Eiffel and NICE are registered trademarks of the Nonprofit International Consortium for Eiffel.

Eiffel "Gotchas"