Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax).
Hint: use the value 0.02 to represent 2 percent, and 0.04 to represent 4 percent.
Python Program:
#Get the purchase amount
purchaseAmount = float(input("Enter the amount of a purchase:"))
#Assign the value to State sales tax percentage
Statesalestaxpercentage = 0.04
#Assign the value to county sales tax percentage
countysalestaxpercentage =0.02
#Calculate the state sales tax
statesalestax = purchaseAmount * Statesalestaxpercentage
#Calculate the county sales tax
countysalestax = purchaseAmount * countysalestaxpercentage
#Calculate the total sales tax
Totalsalestax = statesalestax + countysalestax
#Calculate the total of the sale
Totalofthesale = purchaseAmount + Totalsalestax
#Display the required output
print("The amount of the purchase:",purchaseAmount)
print("The state sales tax:",statesalestax)
print("The county sales tax:",countysalestax)
print("The total sales tax:",Totalsalestax)
print("The total of the sale:",Totalofthesale)
Sample output:
Enter the amount of a purchase:2000
The amount of the purchase: 2000.0
The state sales tax: 80.0
The county sales tax: 40.0
The total sales tax: 120.0
The total of the sale: 2120.0
purchaseAmount = float(input("Enter the amount of a purchase:"))
Statesalestaxpercentage = 0.04
countysalestaxpercentage =0.02
statesalestax = purchaseAmount * Statesalestaxpercentage
countysalestax = purchaseAmount * countysalestaxpercentage
Totalsalestax = statesalestax + countysalestax
Totalofthesale = purchaseAmount + Totalsalestax
print("The amount of the purchase:",purchaseAmount)
print("The state sales tax:",statesalestax)
print("The county sales tax:",countysalestax)
print("The total sales tax:",Totalsalestax)
print("The total of the sale:",Totalofthesale)
Post the discussion to improve the above solution.