Question

In Python 3.7.4 I'm a newbie and this one is really thrown me off. We have...

In Python 3.7.4

I'm a newbie and this one is really thrown me off. We have only learned the very basics: Numbers, strings, lists, tuples, relational and logical operators, if-else, and the 'while' and 'for' loops.

Would you mind explaining the logic behind each step, please? I really want to learn it. Thank you!

------------------------------

Write a program that will compute the total cost of an amazon purchase. The program should ask the user to enter the amount of a purchase, then calculate a 12% shipping and handling fee and NJ sales tax (7%). Your program should show the itemized bill.

Requirements:

  • The use of descriptive variable names (aka self-documenting code)
  • Output displayed with labels and presented in a neat format (e.g. for money $ dd.cc)

-------------------------------

Homework Answers

Answer #1

CODE

# first get the value of purchase amount from user

purchaseAmount = float(input("Enter the purchase amount: "))

# calculate the shipping cost and handling charges

shippingAndHandlingCost = 0.12 * purchaseAmount

# now calculate the sales tax

salesTax = 0.07 * purchaseAmount

# calculate the total amount

totalAmount = purchaseAmount + shippingAndHandlingCost + salesTax

# finally, print the results

print("Purchase amount: $%.2f" %purchaseAmount)

print("Shipping and Handling Fee: $%.2f" %shippingAndHandlingCost)

print("Sales Tax: $%.2f" %salesTax)

print("Total Purchase amount: $%.2f" %totalAmount)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions