Hamilton LaboratoriesHamilton C shell 2012User guideSamples

postage.csh

Oregon Coast

postage.csh
Previous | Next

#  Calculate U.S. first class postage required for a given weight in ounces.
#  Copyright (c) 1991-2012 by Hamilton Laboratories.  All rights reserved.

#  Reflects rates effective January 22, 2012

proc postage(ounces)
   #  Current rate is 45 cents for the first ounce + 20 cents for
   #  each additional ounce or fraction thereof, up to 3.5 ounces.
   #  Over 3.5 ounces, large envelope rates apply, and the rate is
   #  $1.50 for 4 ounces + 20 cents for each additional ounce.

   local cost, nextOunce
   @ nextOunce = ceil(ounces)
   if ( ounces <= 3.5 ) then
      @ cost = .45 + (nextOunce - 1)*.20
   else
      @ cost = 1.5 + (nextOunce - 4)*.20
   end
   return printf('$%.2f', cost)
end

postage $argv

Previous | Next