topical media & game development

talk show tell print

basic-shell-11-trace-here.sh / sh



  
  # Using bc for math with a here document.
  # Calculates sales tax.
  
  echo -n "Please enter the amount of purchase: "
  read amount
  echo
  
  echo -n "Please enter the total sales tax: "
  read rate
  echo
  
  result=$(bc << EndOfCommands
  scale=2   /* two decimal places */
  
  tax = ( amount * rate ) / 100
  total=amount+tax
  
  print total
  
  EndOfCommands
  )
  
  echo "The total with sales tax is: $ result on `date`."
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.