Respuesta :
I created this program in Python.
SMuffin = 10
SCake = 1
NewTrans = 'y' #New transaction added for multiple inputs
while NewTrans == 'y': #While is used for multiple transactions until the user inputs "0".
Scheck = str(input("Enter cupcake or muffin: "))
if Scheck == 'cupcake':
if SCake == 0:
print("Out of stock")
else:
print("Cupcake Sold")
SCake -= 1
elif Scheck == 'muffin':
if SMuffin == 0:
print("Out of stock")
else:
print("Muffin Sold")
SMuffin -= 1
elif Scheck == '0':
print("Muffins:",SMuffin,"Cupcakes:",SCake)
else:
print("Invalid input!")
NewTrans = str(input("New Transaction?: (y/n)"))
if NewTrans == 'n':
print("Muffins:",SMuffin,"Cupcakes:",SCake)
Answer:
buying = input()
while buying != "0":
if buying == "muffin":
if muffins > 0:
muffins -=1
else:
print("Out of stock")
elif buying == "cupcake":
if cupcakes > 0:
cupcakes -=1
else:
print("Out of stock")
buying = input()
print("muffins:", muffins, "cupcakes:", cupcakes)
Explanation:
The program above can be used to determine if a customer will buy a muffin or cupcakes at any given point in time. The program was developed by considering several factors that influence customer's decision such as the number of cupcakes and muffins available as well as the total number of customers' requests at any given time.