#!/usr/bin/env python # # a very simple cash register program # # written by e.bonakdarian oct 2010 # STATE_TAX = 0.08 ########################################################## def banner(): print '-----------------------------------' print ' your own fun banner here' print '-----------------------------------' ########################################################## def computeTotals(number, item_price, description, tax_rate): # compute tax/totals and print out a bill sub_total = number * item_price # computes tax due based on subtotal and tax rate tax = sub_total * tax_rate # is this tax variable really needed? # prints the bill using all available information print print 'Item : %s' % description print 'Number : %4d' % number print 'Item Price: $%7.2f' % item_price print 'SubTotal : $%7.2f' % sub_total print 'Tax : $%7.2f' % tax print '=====================' print 'Total : $%7.2f' % (sub_total + tax) ########################################################## def processPurchase(): # get the inputs from the user and computes and dispaly totals print '\nProgram calculates total cost of same items purchased' print 'state tax is %d percent.\n' % (STATE_TAX * 100) description=raw_input('Enter item description: ') number = input('Number of items purchased? ') item_price = input('Price per item? ') computeTotals(number, item_price, description, STATE_TAX) ########################################################## def main(): # driver for program banner() processPurchase() print processPurchase() banner() main()