In: Computer Science
Calculating delivery charges in Python.
Purchase total > $150 |
Yes |
|||
Number of the items (N) |
N<=5 |
N>=6 |
||
Delivery day |
Same Day |
Next Day |
Same Day |
Next Day |
Delivery charges ($) |
8 |
N * 1.50 |
N * 2.50 |
N * 1.20 |
The user will enter the purchase total, the number of the items and delivery day for calculating the delivery cost. Once the cost has been calculated, the program should correctly display the delivery cost and total cost for the user.
For example, if a user enters “$200” as purchase total, “7” as the number of the items and “1” as delivery in the same day, the program should be able to display the delivery cost of “17.50" and the total cost of “$217.50” ($200 + $17.50 ) for the user.
This program must be built by using sequence programming (without using functions) in Pythoin
Program
pur_cost=int(input("Enter purchase total : "))
no_items=int(input("Enter the number of items:"))
day=int(input("Enter delivery day:"))
if no_items<=5:
if day>1:
del_cost=(no_items*1.5)
else:
del_cost=8
elif no_items>=6:
if day>1:
del_cost=(no_items*1.2)
else:
del_cost=(no_items*2.5)
tot_cost=pur_cost+del_cost
print("Delivery cost:",del_cost)
print("Total Cost:",tot_cost)
Output
Enter purchase total : 200 Enter the number of items:7 Enter delivery day:1 Delivery cost: 17.5 Total Cost: 217.5
Screenshot