Using the knowledge in computational language in python it is possible to write a code that uses enters menu items by name or an assigned item number.
<h3>Writting the code in python:</h3>
<em>#Here, file1 is created as object for menu.txt and file2 as object for bill.txt</em>
<em>#It is done using the open() function.</em>
<em>#No module is required to be imported for this function.</em>
<em>#Here, r represents that this file will be used to read data</em>
<em>#and w represents "write"</em>
<em>file1 = open("menu.txt","r")</em>
<em>file2 = open("bill.txt","w")</em>
<em />
<em>#this is the welcome statement</em>
<em>print ("Welcome to the Delicious Restaurent:")</em>
<em>print("""Enter "I'm done" or "Exit" or "No" to stop the orders.\n""")</em>
<em>print("The menu is as follows:\nPlease enter the item no. to order.\n")</em>
<em />
<em>#readlines(): reads all the lines and return them as each line a string element in a list.</em>
<em>a=file1.readlines()</em>
<em />
<em>#we will iterate though each element and print it to the customer</em>
<em>for i in range(len(a)):</em>
<em> print("{}) {}".format(i+1,a[i]))</em>
<em> </em>
<em>#variable to store the total bill amount</em>
<em>total=0</em>
<em />
<em>#initialize the order variable with 1</em>
<em>order=1</em>
<em />
<em>#taking the input</em>
<em>order=int(input("\nEnter order: "))</em>
<em />
<em>#This loop will continue untill the customer will enter "exit" or "I'm done"</em>
<em>while(order not in ["i'm done", "I'm done" ,"Exit", "exit","No","no"]):</em>
<em> </em>
<em> #if customer enters "i'm done" or "exit", he will break out of loop</em>
<em> if order in ["i'm done", "I'm done" ,"Exit", "exit","no","No"]:</em>
<em> break</em>
<em> </em>
<em> #if customer enters any number between 1 to 12, that item will be added to his bill</em>
<em> if order in range(1,13):</em>
<em> </em>
<em> print("Your order number {} is added.\n".format(order))</em>
<em> </em>
<em> #we will get that item by its order number</em>
<em> item=a[order-1]</em>
<em> </em>
<em> #Here i am using string slicing to get the price(it is after the $ sign)</em>
<em> #We will get the index of $ sign and use the number after that</em>
<em> # for eg. "Egg burger $34.12"</em>
<em> # indexi= 11 (Here $ is at 11th position)</em>
<em> indexi=item.index('$')</em>
<em> </em>
<em> #prici will have the price</em>
<em> prici=(item[indexi+1:])</em>
<em> </em>
<em> #add the price of that item to total value</em>
<em> total+=float(prici)</em>
<em> </em>
<em> #write the item and its price to the output file </em>
<em> file2.write(item)</em>
<em> </em>
<em> #For any other inputs, it will print ("Wrong choice")</em>
<em> else:</em>
<em> print("Wrong choice")</em>
<em> </em>
<em> #It will ask the user, if he/she needs more orders</em>
<em> print("Do you want to add more")</em>
<em> order=(input("Enter order: "))</em>
<em> </em>
<em> #it will convert the user input into an integer, if possible</em>
<em> #because he may enter "exit" also. </em>
<em> try:</em>
<em> order=int(order)</em>
<em> except:</em>
<em> continue</em>
<em />
<em />
<em>#This is the case outside of the while loop.</em>
<em>#Here, Total amount is printed in the bill.</em>
<em>file2.write("----------------------\n")</em>
<em>file2.write("Your Total amount is $"+str(total))</em>
<em />
<em>#We need to close those files as well</em>
<em>#close() function closes the file and frees the memory space acquired by that file. </em>
<em>file1.close()</em>
<em>file2.close()</em>
See more about python at brainly.com/question/18502436
#SPJ1