Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions