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:4 | ISBN:9780132576376 | Edition: 2

Question

A customer in a store is purchasing five items. Write a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total. Assume the sales tax is 6 percent.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Python code:

salestax = 0.06
item1=float(input("Enter the price of first item:"))
item2=float(input("Enter the price of second item:"))
item3=float(input("Enter the price of third item:"))
item4=float(input("Enter the price of four item:"))
item5=float(input("Enter the price of five item:"))
subtotal =item1+item2+item3+item4+item5
print("The subtotal of the sale:",subtotal)
anountofsalestax = subtotal * salestax
print("The amount of sales tax:",anountofsalestax)
Total = subtotal + anountofsalestax
print("Total:",Total)

Sample output:

>>> 
Enter the price of first item:20
Enter the price of second item:30
Enter the price of third item:40
Enter the price of four item:50
Enter the price of five item:60
The subtotal of the sale: 200.0
The amount of sales tax: 12.0
Total: 212.0
>>> 

 

0 0

Discussions

S

salestax = 0.06
item1=float(input("Enter the price of first item:"))
item2=float(input("Enter the price of second item:"))
item3=float(input("Enter the price of third item:"))
item4=float(input("Enter the price of four item:"))
item5=float(input("Enter the price of five item:"))
subtotal =item1+item2+item3+item4+item5
print("The subtotal of the sale:",subtotal)
anountofsalestax = subtotal * salestax
print("The amount of sales tax:",anountofsalestax)
Total = subtotal + anountofsalestax
print("Total:",Total)

 

Post the discussion to improve the above solution.