Question: Sales Tax Program Refactoring in PYTHON Programming Excercis #6 in Chapter 2 was the Sales Tax program. For that exercise, you were asked to write

Sales Tax Program Refactoring in PYTHON

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.

Chapter 2 code 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!