Question: from decimal import Decimal from decimal import ROUND_HALF_UP # display a title print(The Invoice program) print() choice = y while choice == y: # get

from decimal import Decimal from decimal import ROUND_HALF_UP

# display a title print("The Invoice program") print()

choice = "y" while choice == "y": # get the user entry order_total = Decimal(input("Enter order total: ")) order_total = order_total.quantize(Decimal("1.00"), ROUND_HALF_UP) print()

# determine the discount percent if order_total > 0 and order_total < 100: discount_percent = Decimal("0") elif order_total >= 100 and order_total < 250: discount_percent = Decimal(".1") elif order_total >= 250: discount_percent = Decimal(".2")

# calculate the results discount = order_total * discount_percent discount = discount.quantize(Decimal("1.00"), ROUND_HALF_UP) subtotal = order_total - discount tax_percent = Decimal(".05") sales_tax = subtotal * tax_percent sales_tax = sales_tax.quantize(Decimal("1.00"), ROUND_HALF_UP) invoice_total = subtotal + sales_tax

# display the results print(f"Order total: {order_total:10,}") print(f"Discount amount: {discount:10,}") print(f"Subtotal: {subtotal:10,}") print(f"Sales tax: {sales_tax:10,}") print(f"Invoice total: {invoice_total:10,}") print()

choice = input("Continue? (y/n): ") print() print("Bye!")

Use the code above:

You will modify the Invoice program so that the program formats currency values correctly.

You will also add and calculate a shipping cost to the output.

Review the code and run the program so that you understand the starting point.

Modify the program so that it displays the order total and invoice total as U.S. currency values with dollar signs and two decimal points.

Add a shipping cost which should be 8.5% (.085) of the subtotal. Use the decimal module to make sure each monetary value has the correct number of decimal places.

Ensure that you have a title/greeting in your output. Be sure to have an exit message too.

Test and debug the program to make sure it works.

Be sure to comment your code to explain the process. Include your name, date, class and assignment name in the comments at the top of the program.

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!