def setup():
packageType = 2
serviceType = 3
weight = 16
print("Expressimo Delivery Service")
charge(packageType, serviceType, weight)
def charge(package_type, service_type, weight):
cost = 0
if (package_type == 1):
print("Package : LETTER");
if (service_type == 1):
print("Service : Next day Priority")
if (weight <= 8):
cost = 12
else:
cost = 0
elif (service_type == 2):
print("Service : Next day Standard")
if (weight <= 8):
cost = 10.5
else:
cost = 0
elif (service_type == 3):
print("Service : No Service")
else:
print("Service : ERROR")
print("Weight : ",weight," Oz")
elif (package_type == 2):
print("Package : BOX")
if (service_type == 1):
print("Service : Next day Priority")
if (weight <= 1):
cost = 15.75
else:
cost = cal_service1(weight)
elif (service_type == 2):
print("Service : Next day Standard")
if (weight <= 1):
cost = 13.75
else:
cost = cal_service2(weight)
elif (service_type == 3):
print("Service : Two-days")
if (weight <= 1):
cost = 7.00
else:
cost = cal_service3(weight)
else:
print("Service : ERROR")
print("Weight :",weight,"Pound")
else:
print("Package : ERROR")
print("Charge : $",cost)
def cal_service1(weight):
firstCharge = 15.75
priority_charge = firstCharge + ((weight-1)*1.25)
return priority_charge
def cal_service2(weight):
firstCharge = 13.75;
standard_charge = firstCharge + ((weight-1)*1)
return standard_charge
def cal_service3(weight):
firstCharge = 7.00
twodays_charge = firstCharge + ((weight-1)*0.5)
return twodays_charge
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น