Answer:
- def calculateOrder():
- pound = float(input("Enter number of pound ordered: "))
- COST_PER_POUND = 10.5
- SHIP_PER_POUND = 0.86
- OVERHEAD = 1.5
- shipping = SHIP_PER_POUND * pound
- total_cost = pound * COST_PER_POUND + shipping + OVERHEAD
- print("Total cost: $" + str(total_cost))
-
- calculateOrder()
Step-by-step explanation:
The solution code is written in Python 3.
Firstly we declare a function calculateOrder (Line 1). Next we use input function to prompt user to enter the number of pound of coffee they wish to order (Line 2). Create three constant variables to hold the value of cost per pound, shipping fee per pound and the overhead charge (Line 3-5). We first calculate the shipping charge (Line 6) and then adding the shipping charge along with the cost for coffee ordered and the overhead charge (Line 7). Lastly, print the total cost (Line 8).
We test the function (Line 10).