Lesson One Homework Solution
Copyright 2007 Shoptalk Systems
All Rights Reserved

Return to Table of Contents

[start]

  'Ask for a dollar and cent amount
  print "Type a dollar and cent amount."
  input "(Press 'Enter' alone for help) ?"; amount

  'Display help if user pressed [Enter]
  if amount = 0 then [help]

  'Calculate tax for the nearest 20 cent multiple
  dollars = int(amount)

  dollarsTax = dollars * 0.05
  cents = amount - dollars
  adjustment = 0.10
  centsAdjusted = cents + adjustment
  centsRounded = int(centsAdjusted / 0.20) * 0.20
  centsTax = (centsRounded / 0.20) / 100
  tax = dollarsTax + centsTax

  'Display the amount, tax, and total
  print "Product Price $"; using("#####.##", amount)
  print "Sales Tax      "; using("#####.##", tax)

  print "------------------------"
  print "Total          "; using("#####.##", tax + amount)
  print
  goto [start]

[help]
  cls
  print "SALESTAX.BAS Help"
  print
  print "This tax program determines how much tax is"
  print "due on an amount entered and also computes"
  print "the total amount. The tax rate is 5%."
  print
  input "Press [Enter] to continue."; dummyVariable
  cls
  goto [start]