Question

In: Computer Science

How would I modify this Python Program to include two different if statement structures? "For this...

How would I modify this Python Program to include two different if statement structures? "For this program, decisions may include adding different charges to a tables' check based on what the diner orders, and/or deciding when to quit the program, among other possibilities. "

def display_menu_items():
   print("item cost")
   print("1.item-1 5")
   print("2.item-2 10")
   print("3.item-3 15")
   print("4.item-4 50")
   print("5.item-5 25")
   print("6.item-6 2")
   print("7.item-7 26")


def main():
   print("Enter -1 to quit manager or any other number to continue")
   enter_to_quit=int(input())
   if (enter_to_quit==-1):
       quit()
   print("enter table number")
   table_number=int(input())
  
   print("enter no.of diners (maximum limit 4)")
   number_of_diners=int(input())
  
   print("select an item and enter -1 to exit")
   items=[]
   item_number=[]
   select=0
   ch=[0,5,10,15,50,25,2,26]
   display_menu_items()
  
   while ( select is not -1):
       items.append(ch[select])
       item_number.append(select)
       select=int(input())
  
   total_items_cost=0
  
   for i in items:
       total_items_cost=total_items_cost+i
  
   print("Total cost without tax =",total_items_cost)
   total_cost=total_items_cost+(total_items_cost/100)*8
  
   print("cost for individual diner =",total_cost/number_of_diners)
   print("total cost with tax = ",total_cost)
   print("suggestions for tip 1.10% 2.15% 3.20% 4.25% ")
  
   tip=int(input())
   tip_list=[10,15,20,25]
   total_tip=tip_list[tip]
   total_tip=(total_cost/100)*total_tip
  
   print("table information")
   print("table no:- ",table_number)
   print("selected items:-")
  
   item_list=["item-1","item-2","item-3","item-4","item-5","item-6","item-7"]
  
   for i in range(1,len(items)):
       print(item_list[item_number[i]-1])
   print("total cost= ",total_cost)
   print("tip= ",total_tip)
   print("total cost with tip= ",total_cost+total_tip)
   main()

Solutions

Expert Solution

def display_menu_items():
   print("item cost")
   print("1.item-1 5")
   print("2.item-2 10")
   print("3.item-3 15")
   print("4.item-4 50")
   print("5.item-5 25")
   print("6.item-6 2")
   print("7.item-7 26")


def main():
   print("Enter -1 to quit manager or any other number to continue")
   enter_to_quit=int(input())
   if (enter_to_quit==-1):
       quit()
   print("enter table number")
   table_number=int(input())

   print("enter no.of diners (maximum limit 4)")
   number_of_diners=int(input())

   print("select an item and enter -1 to exit")
   items=[]
   item_number=[]
   select=0
   ch=[0,5,10,15,50,25,2,26]
   display_menu_items()

   while ( select is not -1):
      items.append(ch[select])
      item_number.append(select)
      select=int(input())

   total_items_cost=0

   for i in items:
     total_items_cost=total_items_cost+i

   print("Total cost without tax =",total_items_cost)

   # ADDING NEW IF STATEMENT
   choice = int(input('Enter any number to if you qualify for discount, or else -1: '))
   if choice != -1:
      # give 5% discount
      total_items_cost = total_items_cost * 0.95 

   total_cost=total_items_cost+(total_items_cost/100)*8
   print("cost for individual diner =",total_cost/number_of_diners)

   print("total cost with tax = ",total_cost)
   print("suggestions for tip 1.10% 2.15% 3.20% 4.25% ")

   # ADDDED IF STATEMENT HERE
   total_tip = 0
   choice = int(input('Enter any number to give tip, or else -1: '))
   if choice != -1:
     tip=int(input())
     tip_list=[10,15,20,25]
     total_tip=tip_list[tip]
     total_tip=(total_cost/100)*total_tip

   print("table information")
   print("table no:- ",table_number)
   print("selected items:-")

   item_list=["item-1","item-2","item-3","item-4","item-5","item-6","item-7"]

   for i in range(1,len(items)):
       print(item_list[item_number[i]-1])
   print("total cost= ",total_cost)
   print("tip= ",total_tip)
   print("total cost with tip= ",total_cost+total_tip)


main()

Related Solutions

Python: How would I modify the class below that takes a string and returns an object...
Python: How would I modify the class below that takes a string and returns an object holding a valid NANP phone number. I am asked to filll in the three methods listed, but underfined, below: __str__(), area_code(), and normalize(). My task is to clean up differently formatted telephone numbers by removing punctuation, such as '(', '-', and the like, and removing and the country code (1) if present. I am asked to start by stripping non-digits, and then see if...
Honeycutt Co. is comparing two different capital structures. Plan I would result in 22,000 shares of...
Honeycutt Co. is comparing two different capital structures. Plan I would result in 22,000 shares of stock and $79,500 in debt. Plan II would result in 16,000 shares of stock and $238,500 in debt. The interest rate on the debt is 6 percent.    a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $75,000. The all-equity plan would result in 25,000 shares of stock outstanding. What is the EPS for each of...
Coldstream Corp. is comparing two different capital structures. Plan I would result in 16,000 shares of...
Coldstream Corp. is comparing two different capital structures. Plan I would result in 16,000 shares of stock and $100,000 in debt. Plan II would result in 12,000 shares of stock and $200,000 in debt. The interest rate on the debt is 6 percent. a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $80,000. The all-equity plan would result in 20,000 shares of stock outstanding. What is the EPS for each of these...
Haskell Corp. is comparing two different capital structures. Plan I would result in 12,000 shares of...
Haskell Corp. is comparing two different capital structures. Plan I would result in 12,000 shares of stock and $100,000 in debt. Plan II would result in 4,000 shares of stock and $200,000 in debt. The interest rate on the debt is 8 percent. a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $70,000. The all-equity plan would result in 20,000 shares of stock outstanding. What is the EPS for each of these...
Silverton Co. is comparing two different capital structures. Plan I would result in 8,000 shares of...
Silverton Co. is comparing two different capital structures. Plan I would result in 8,000 shares of stock and $410,400 in debt. Plan II would result in 12,450 shares of stock and $250,200 in debt. The interest rate on the debt is 10 percent. a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $53,300. The all-equity plan would result in 19,400 shares of stock outstanding. Compute the EPS for each plan. (Do not...
Destin Corp. is comparing two different capital structures. Plan I would result in 10,000 shares of...
Destin Corp. is comparing two different capital structures. Plan I would result in 10,000 shares of stock and $90,000 in debt. Plan II would result in 7,600 shares of stock and $198,000 in debt. The interest rate on the debt is 10 percent.    a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $48,000. The all-equity plan would result in 12,000 shares of stock outstanding. What is the EPS for each of...
Silverton Co. is comparing two different capital structures. Plan I would result in 8,500 shares of...
Silverton Co. is comparing two different capital structures. Plan I would result in 8,500 shares of stock and $402,500 in debt. Plan II would result in 12,000 shares of stock and $280,000 in debt. The interest rate on the debt is 11 percent. a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $54,500. The all-equity plan would result in 20,000 shares of stock outstanding. Compute the EPS for each plan. (Do not...
Destin Corp. is comparing two different capital structures. Plan I would result in 10,000 shares of...
Destin Corp. is comparing two different capital structures. Plan I would result in 10,000 shares of stock and $100,000 in debt. Plan II would result in 5,000 shares of stock and $200,000 in debt. The interest rate on the debt is 6 percent.    a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $60,000. The all-equity plan would result in 15,000 shares of stock outstanding. What is the EPS for each of...
Silverton Co. is comparing two different capital structures. Plan I would result in 9,000 shares of...
Silverton Co. is comparing two different capital structures. Plan I would result in 9,000 shares of stock and $342,000 in debt. Plan II would result in 12,600 shares of stock and $205,200 in debt. The interest rate on the debt is 10 percent. a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $53,500. The all-equity plan would result in 18,000 shares of stock outstanding. Compute the EPS for each plan. (Do not...
Bellwood Corp. is comparing two different capital structures. Plan I would result in 12,700 shares of...
Bellwood Corp. is comparing two different capital structures. Plan I would result in 12,700 shares of stock and $109,250 in debt. Plan II would result in 9,800 shares of stock and $247,000 in debt. The interest rate on the debt is 10 percent.    a. Ignoring taxes, compare both of these plans to an all-equity plan assuming that EBIT will be $79,000. The all-equity plan would result in 15,000 shares of stock outstanding. What is the EPS for each of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT