Ask Question
17 March, 20:58

You work for a bakery that sells two items: muffins and cupcakes. the number of muffins and cupcakes in your shop at any given time is stored in the variables muffins and cupcakes, which have been defined for you. write a program that takes strings from standard input indicating what your customers are buying ("muffin" for a muffin, "cupcake" for a cupcake). if they buy a muffin, decrease muffins by one, and if they buy a cupcake, decrease cupcakes by 1. if there is no more of that baked good left, print ("out of stock"). once you are done selling, input "0", and have the program print out the number of muffins and cupcakes remaining, in the form "muffins: 9 cupcakes: 3" (if there were 9 muffins and 3 cupcakes left, for example).

+5
Answers (1)
  1. 17 March, 21:12
    0
    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)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “You work for a bakery that sells two items: muffins and cupcakes. the number of muffins and cupcakes in your shop at any given time is ...” in 📗 Business if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers