Computer Science, asked by chshmish29451, 11 months ago

Foodcorner home delivers vegetarian and non-vegetarian combos to its customer based on order. A vegetarian combo costs rs.120 per plate and a non-vegetarian combo costs rs.150 per plate. Their non-veg combo is really famous that they get more orders for their non-vegetarian combo than the vegetarian combo. Apart from the cost per plate of food, customers are also charged for home delivery based on the distance in kms from the restaurant to the delivery point. The delivery charges are as mentioned below: distance in kms delivery charge in rs per km for first 3kms 0 for next 3kms 3 for the remaining 6 given the type of food, quantity (no. Of plates) and the distance in kms from the restaurant to the delivery point, write a python program to calculate the final bill amount to be paid by a customer. The below information must be used to check the validity of the data provided by the customer: type of food must be v' for vegetarian and n' for non-vegetarian. Distance in kms must be greater than 0. Quantity ordered should be minimum 1. If any of the input is invalid, the bill amount should be considered as -1.

Answers

Answered by gjanani2000
15

Answer:

def calculate_bill_amount(food_type,quantity_ordered,distance_in_kms):

   bill_amount=0

   #write your logic here

   if((food_type=="V" or food_type=="N")and quantity_ordered>0):  

       if(food_type=="V"):

           food_cost=120*quantity_ordered

       elif(food_type=="N"):

           food_cost=150*quantity_ordered

       else:

           food_cost=0    

       if(distance_in_kms>=0) :

           if(0<distance_in_kms<=3):

               bill_amount=(0*distance_in_kms)+ food_cost

           elif(3<distance_in_kms<=6):

               bill_amount=(3*(distance_in_kms-3))+ food_cost

           elif(distance_in_kms==0):

               bill_amount =-1    

           else:

               bill_amount=((6*(distance_in_kms-6))+9)+ food_cost

       else:

           bill_amount =-1

   else:

       bill_amount=-1

   return bill_amount

bill_amount=calculate_bill_amount("N",2,7)

print(bill_amount)

Explanation:

Answered by 2000achuthans
1

Answer:

def calculate_bill_amount(food_type,quantity_ordered,distance_in_kms):

   bill_amount=0

   if(food_type=="V" or "N" and quantity_ordered>0 and distance_in_kms>0):

       if(distance_in_kms<=3):

           travel_fee=0

       elif(distance_in_kms>3 and distance_in_kms<=6):

           travel_fee=3*(distance_in_kms-3)

       else:

           travel_fee=6*(distance_in_kms-6)+9

       

       if(food_type=="V"):

           bill_amount=120*quantity_ordered+travel_fee

       elif(food_type=="N"):

           bill_amount=150*quantity_ordered+travel_fee

       else:

           bill_amount=-1

       

   else:

       bill_amount=-1

       

   return bill_amount

bill_amount=calculate_bill_amount("N",2,7)

print(bill_amount)

Explanation:

Similar questions