วันอาทิตย์ที่ 20 กันยายน พ.ศ. 2558

Lab4x-Service Charge

def serviceCharge(typeOfPackage, typeOfService, weightOfPackage):
   cost=0
   textTypePac="type of package is"
   textTypeSer="type of service is"
   textWeight="Weight of package is"
   if(typeOfPackage==1):
      print(textTypePac,"Letter")
      print(textWeight,weightOfPackage,"oz")
   elif(typeOfPackage==2):
      print(textTypePac,"Box")
      print(textWeight,weightOfPackage,"pound")
   else:
      print("Not Found")
   
   if(typeOfService==1):
      print(textTypeSer,"Next Day Priority")
   elif(typeOfService==2):
      print(textTypeSer,"Next Day Standard")
   elif(typeOfService==3):
      print(textTypeSer,"Two-Day")
   else:
      print(textTypeSer,"Not Found")
   
   if(typeOfPackage==1):
      if(typeOfService==1 and weightOfPackage<=8):
         cost=12
      elif(typeOfService==2 and weightOfPackage<=8):
         cost=10
      else:
         print("No Service")
       
   if(typeOfPackage==2):
      if(typeOfService==1):
         if(weightOfPackage<=1):
             cost=15.75
         elif(weightOfPackage>1):
             cost=15.75+((weightOfPackage-1)*1.25)
      elif(typeOfService==2):
         if(weightOsPackage<=1):
             cost=13.75
         elif(weightOfPackage>1):
             cost=13.75+((weightOfPackage-1)*1.00)
      elif(typeOfService==3):
         if(weightOfPackage<=1):
             cost=7
         elif(weightOfPacksge>1):
             cost=7+ ((weightOfPackage-1)*0.50)
      print("Charge: $",cost)
   
serviceCharge(2,1,20)

ไม่มีความคิดเห็น:

แสดงความคิดเห็น