Question
Sales Tax Program Refactoring Programming Excercis #6 in Chapter 2 was the Sales Tax program. For that exercise, you were asked to write a program
Sales Tax Program Refactoring
Programming Excercis #6 in Chapter 2 was the Sales Tax program. For that exercise, you were asked to write a program that calculates and displays the county and state sales tax on a purchase. If you havbe already written that program, re disgin it so the subtasks are in functions. If you have not already written that program, write it using functions.
COde in sales tax is
#Python program that prompts amount and calculates the state tax #county sales and print the amount and tax #constant values for state and county tax STATE_TAX = .05 COUNTY_TAX = .025
def main ():
#call user_input this in turn calls the rest of functios user_input() def user_input(): price = float(input('Enter an amount : ')) state_salesTax = price * STATE_TAX county_sales_tax = price * COUNTY_TAX print("State sales tax is $ {0:12,.2f}".format(state_salesTax)) print("County sales tax $ {0:12,.2f}".format(county_sales_tax))
#add county_sales_tax and state_salesTax taxaddition = county_sales_tax + state_salesTax #call from this location to the method addition_of_tax #to print the addition of two taxes addition_of_tax(taxaddition) #add price ad taxaddition tax_after_purchase = price + taxaddition #call from this location to the method purchase_after_tax #to print the tax_after_purchase purchase_after_tax( tax_after_purchase)
#print taxaddition def addition_of_tax(taxaddion ): print("Tax addition ${0:12,.2f}".format(taxaddion))
#prit amount and tax def purchase_after_tax( tax_after_purchase): print("Amount + Tax $ : {0:12,.2f}".format(tax_after_purchase))
main ()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started