วันพุธที่ 16 กันยายน พ.ศ. 2558

LAB 4 extra service

def choice(package,service,oz):
   pond = oz/16
   if(package=="box"):
      if(service=="2day"):
         cost = 7+((pond-1)*0.5)
         if(cost<7):
            cost=7
      if(service=="next day standard"):
         cost = 13.75+(pond-1)
         if(cost<13.75):
            cost=13.75
      if(service=="next day priority"):
         cost = 15.75+((pond-1)*1.25)
         if(cost<15.75):
            cost=15.75
   if(package=="letter"):
      if(oz>8):
         cost = "(cant use this service)"
      else:
         if(service=="2day"):
            cost = "(sorry that not available)"
         if(service=="next day standard"):
            cost = 10.50
         if(service=="next day priority"):
            cost = 12.00
   print("you chois is",package,"and",service,oz,"Oz","your cost is",cost)
choice("box","2day",16)
choice("box","2day",32)
choice("box","next day standard",16)
choice("box","next day standard",32)
choice("box","next day priority",16)
choice("box","next day priority",32)

choice("letter","2day",16)
choice("letter","2day",32)
choice("letter","next day standard",8)
choice("letter","next day standard",7)
choice("letter","next day priority",8)
choice("letter","next day priority",9)


ผลลัพธ์

you chois is box and 2day 16 Oz your cost is 7.0
you chois is box and 2day 32 Oz your cost is 7.5
you chois is box and next day standard 16 Oz your cost is 13.75
you chois is box and next day standard 32 Oz your cost is 14.75
you chois is box and next day priority 16 Oz your cost is 15.75
you chois is box and next day priority 32 Oz your cost is 17.0
you chois is letter and 2day 16 Oz your cost is (cant use this service)
you chois is letter and 2day 32 Oz your cost is (cant use this service)
you chois is letter and next day standard 8 Oz your cost is 10.5
you chois is letter and next day standard 7 Oz your cost is 10.5
you chois is letter and next day priority 8 Oz your cost is 12.0
you chois is letter and next day priority 9 Oz your cost is (cant use this service)

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

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