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:
-------------------------------
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)
Get Answers For Free
Most questions answered within 1 hours.