Explanation:
The menu is provided as given in the question. A while loop is used to keep getting input from the user until the user enters exit value 0. If elif commands are used to keep track of the respective muffins. Three counters are used to keep the count of each muffin and at the end the quantity of each muffin is multiplied with the price of each muffin then added together to get the total bill.
Python Code:
menu="""****************MENU*******************
Please select your muffins:
Press 1 for blueberry muffin $2.98
Press 2 for chocolate chip muffin $4.50
Press 3 for banana muffin $9.98
Press 0 for exit!
***************************************"""
print(menu)
blue=0
chock=0
banana=0
flag=0
while flag==0:
inp=eval(input())
if inp==1:
blue+=1
print("blueberry muffin added")
elif inp==2:
chock+=1
print("chocolate muffin added")
elif inp==3:
banana+=1
print("banana muffin added")
elif inp==0:
break
else:
print("invalid selection!")
print("Your bill is: $",blue*2.98+chock*4.50+banana*9.98)
Output:
*******************MENU**********************
Please select your muffins:
Press 1 for blueberry muffin $2.98
Press 2 for chocolate chip muffin $4.50
Press 3 for banana muffin $9.98
Press 0 for exit!
***************************************"*********
2
chocolate muffin added
3
banana muffin added
5
invalid selection!
1
blueberry muffin added
0
Your bill is: $ 17.46