SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Input,processing And Output
Exercise:
Programming Exercises
Question:6 | ISBN:9780132576376 | Edition: 2

Question

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.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

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

 

0 0

Discussions

S

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.