In: Computer Science
Python Programming- 9.12 S80 MT Practice 2
"""
Enhance your simple food receipt
a. Ask the user for inputs about two food items using the following
prompts in turn [add a space after each
question mark]. Do not forget to assign each user
entry to a unique variable name (do not display the Note to add a
space just use print() to add a space between each
set of input statements):
Name 1? [add a space after the question mark]
Price 1? [add a space after the question mark]
Quantity 1? [add a space after the question mark]
[Note: add space here using print()]
Name 2? [add a space after the question mark]
Price 2? [add a space after the question mark]
Quantity 2? [add a space after the question mark]
[Note: add space here using print()]
Name 3? [add a space after the question mark]
Price 3? [add a space after the question mark]
Quantity 3? [add a space after the question mark]
[Note: add space here using print()]
b. Convert the price and quantity variables to floats
c. Calculate the total cost for the order by calculating each
item's total price by
multiplying price and quantity for each item and then adding up the
total prices for the three items
d. Calculate the total cost plus tax for the order by multiplying
the total cose calculated in c by the tax
rate of .0545 (5.45 percent tax) then adding the tax to the total
cost
e. Display the results using the structure below. Edit the format
string "${:,.2f}".format(identfier) to format the
results of your calculation as currency with the NTD currency type,
a space between NTD and the calculated costs,
and 3 decimal places:
Summary of Charges
You ordered: [Item Name 1] [Item Name 2] [Item Name 3]
Your cost: [total price for all items calculated in 3c above,
formatted with NTD currency, a space & 3 decimal places]
Your cost w tax: [total cost plus tax calculated in 3d above,
formatted with NTD currency, a space & 3 decimal places]
"""
#Start your code below
Code:
n1 = input("Name 1? ")
q1 = input("Quantity 1? ")
p1 = input("Price 1? ")
print()
n2 = input("Name 2? ")
q2 = input("Quantity 2? ")
p2 = input("Price 2? ")
print()
n3 = input("Name 3? ")
q3 = input("Quantity 3? ")
p3 = input("Price 3? ")
print()
q1 = float(q1)
p1 = float(p1)
q2 = float(q2)
p2 = float(p2)
q3 = float(q3)
p3 = float(p3)
amount = p1*q1 + p2*q2 + p3*q3
total = amount + (amount * 0.0545)
print("You Ordered: %s %s %s" % (n1, n2, n3))
print("Your Cost:${:,.2f}".format(amount))
print("Your Cost w tax:${:,.2f}".format(total))
Output: