Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, can anyone help me to figure out this problem, I am really confused, how

ID: 3666427 • Letter: H

Question

Hello, can anyone help me to figure out this problem, I am really confused, how to create this program in Python..

Homework Assignment 3, Restaurant Order Program

This assignment is designed to illustrate the use of tuples, lists and dictionaries in the python programming language and the development of algorithms using those data structures.

1.A list of menu options will be stored in a tuple. These menu options will be displayed to the user to indicate desired functionality. The menu options will be: Display the items on order; Add to the count of an ordered item; Decrease the count of an ordered item; Add a new item to the order; Delete an item from the order, and Exit.

2.A list data structure will be used to contain the names of all items in the order.

3.You will use a dictionary structure to maintain a count of the ordered items. The dictionary will be indexed by the item name, which you stored in the list data structure. The dictionary will also contain the count for each ordered item.

Your program will behave as follows:

1. The program will prompt the user to select an operation from a menu. The menu will be stored in a tuple data structure. The selection will be by menu item number:

1– Display the Order

2– Add an Item to the Order

3– Delete an Item from the Order

4– Increase Count of an Item on Order

5– Decrease Count of an Item on Order

6– Exit

2.The tuple data structure will be exactly:

menu = ("Display Order", "Add an Item", "Delete an Item", "Increase Count of Item", "Decrease Count of Item", "Exit")             

As you can see, the menu item number is not part of the tuple and will have to be calculated when the menu is displayed.

3.The inventory will start as an empty list data structure.  

a.The “Display Order” menu item will display the items on order, along with the count of each item.

b.To add a new item to the order, the program will prompt for a single string. The list will be updated with the new item added to the order. New items should be created with a count of 1.

c.If the user attempts to add an item already on order, an error message will be displayed and the program will return to the menu prompt as shown in item #1.

d.To remove an item from the order, the program should display the inventory items along with a number in a manner similar to the menu in item #1. The item will be selected by number and not by name.

4.The same approach used in 3(d) will be used for increasing and decreasing the count of an item already on order. The program must ask the user for a number indicating the amount to increase or decrease the count for that item. If the user subtracts a count that exceeds the current count, then an appropriate error message should be displayed and the menu from item #1 displayed.

Not that if an item on order is reduced to zero, then the item should be removed from the order. Be sure to allow for this.

Your program should account for obvious errors:

1.Trying to add an item already on order

2.Trying to delete an item not on order

3.Trying to delete more than the count listed for that item

Example Output Below (user input is underlined and in bold). The dashed lines are cosmetic only, so you do not need to have them in your output. You may include different cosmetic style if you wish:

Welcome to the Restaurant Order Program!

What would you like to order?

Use the menu selections provided.

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 1

There are no items on order.

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 2

Enter Item Name: Veggie Burger

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 2

Enter Item Name: Veggie Burger

Error! That item is already on order.

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 2

Enter Item Name: French Fries

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 1

French Fries, quantity: 1

Veggie Burger, quantity: 1

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 4

Item 1 - French Fries, current quantity on order: 1

Item 2 - Veggie Burger, current quantity on order: 1

Enter menu item number to modify: 1

Amount to increase the item: 2

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 1

French Fries, quantity: 3

Veggie Burger, quantity: 1

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 5

Item 1 - French Fries, current quantity on order: 3

Item 2 - Veggie Burger, current quantity on order: 1

Enter menu item number to modify: 2

Amount to decrease the item: 2

Error! You cannot delete more items than are on order.

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 2

Enter Item Name: Soda

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 1

French Fries, quantity: 3

Veggie Burger, quantity: 1

Soda, quantity: 1

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 3

Item 1 - French Fries

Item 2 - Veggie Burger

Item 3 - Soda

Enter menu item number to delete: 2

Successfully Deleted: Veggie Burger

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 1

French Fries, quantity: 3

Soda, quantity: 1

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 5

Item 1 - French Fries, current quantity on order: 3

Item 2 – Soda, current quantity on order: 1

Enter menu item number to modify: 1

Amount to decrease the item: 2

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 1

French Fries, quantity: 1

Soda, quantity: 1

-- -- -- -- -- -- -- -- -- -- -- --

1 - Display the Order

2 - Add an Item

3 - Delete an Item

4 - Increase Count of Item

5 - Decrease Count of Item

6 - Exit

Enter menu item number: 6

Explanation / Answer

Dear Student

I got the code like this .

Please try to simulate with your requirments

)
    return clock

def cr(string):
    return "%s" % string

def cy(string):
    return "%s" % string

def cg(string):
    return "%s" % string

def cb(string):
    return "%s" % string

def cm(string):
    return "%s" % string

def cgray(string):
    return "%s" % string

global ic_in, ic_go, ic_lv, ic_info, ic_ask, ic_mon, ic_stop, ic_dang

ic_in   = cy("[w]")
ic_go   = cy("[v]")
ic_lv   = cy("[^]")
ic_info = cb("[i]")
ic_ask = cm("[?]")
ic_mon = cg("[$]")
ic_stop = cr("[#]")
ic_dang = cr("[!]")

"""
Waiting lane class
"""
class waitingLane(object):

    def __init__(self, env):
        self.env = env
        self.lane = simpy.Resource(env, 3)

    def serve(self, cust):
        yield self.env.timeout(0)
        print("%s (%s) %s entered the area" % (ic_in, toc(env.now), cust))

"""
First+Second counter class
"""
class counterFirstSecond(object):

    def __init__(self, env):
        self.env = env
        self.employee = simpy.Resource(env, 1)

    def serve(self, cust):
        yield self.env.timeout(random.randint(TIME_COUNTER_A-1, TIME_COUNTER_A+1))
        print("%s (%s) %s ordered the menu" % (ic_ask, cgray(toc(env.now)), cust))

        yield self.env.timeout(random.randint(TIME_COUNTER_B-1, TIME_COUNTER_B+1))
        print("%s (%s) %s paid the order" % (ic_mon, toc(env.now), cust))

"""
First counter class
"""
class counterFirst(object):

    def __init__(self, env):
        self.env = env
        self.employee = simpy.Resource(env, 1)

    def serve(self, cust):
        yield self.env.timeout(random.randint(TIME_COUNTER_A-1, TIME_COUNTER_A+1))
        print("%s (%s) %s ordered the menu" % (ic_ask, toc(env.now), cust))

"""
Second counter class
"""
class counterSecond(object):

    def __init__(self, env):
        self.env = env
        self.employee = simpy.Resource(env, 1)

    def serve(self, cust):
        yield self.env.timeout(random.randint(TIME_COUNTER_B-1, TIME_COUNTER_B+1))
        print("%s (%s) %s paid the order" % (ic_mon, toc(env.now), cust))

"""
Third counter class
"""
class counterThird(object):

    def __init__(self, env):
        self.env = env
        self.employee = simpy.Resource(env, 1)

    def serve(self, cust):
        yield self.env.timeout(random.randint(TIME_COUNTER_C-1, TIME_COUNTER_C+1))
        print("%s (%s) %s took the order" % (ic_stop, toc(env.now), cust))

"""
The customer process (each customer has a name)
arrives at the drive-thru lane, counter, then serviced by the empoyee (ce).
It then starts the service process for each counters then leaves.
"""

"""
(Type 2) Define customer behavior at first counter
"""
def customer2A(env, name, wl, ce12, ce3):

    with wl.lane.request() as request:

        if (env.now >= SIM_TIME):
            print("%s Not enough time! %s cancelled" % (ic_dang, name))
            env.exit()

        yield request
        yield env.process(wl.serve(name))
        print("%s (%s) %s is in waiting lane" % (ic_in, toc(env.now), name))

    # Start the actual drive-thru process
    print("%s (%s) %s goes into drive-thru counter" % (ic_go, toc(env.now), name))

    with ce12.employee.request() as request:

        if (env.now + TIME_COUNTER_A + TIME_COUNTER_B >= SIM_TIME):
            print("%s Not enough time! Assumed %s is quickly finished" % (ic_dang, name))
            yield env.timeout(0.5)
            env.exit()

        yield request

        CALC[int(name[5:])] = env.now
        yield env.process(ce12.serve(name))
        print("%s (%s) %s choose the order" % (ic_ask, toc(env.now), name))

        yield env.process(ce12.serve(name))
        print("%s (%s) %s is paying and will take the order" % (ic_mon, toc(env.now), name))
        env.process(customer2B(env, name, ce12, ce3))

"""
(Type 2) Define customer behavior at second counter
"""
def customer2B(env, name, ce12, ce3):

    with ce3.employee.request() as request:

        if (env.now + TIME_COUNTER_C >= SIM_TIME):
            print("%s Not enough time! Assumed %s is quickly finished" % (ic_dang, name))
            yield env.timeout(0.5)
            env.exit()

        yield request

        yield env.process(ce3.serve(name))
        print("%s (%s) %s leaves" % (ic_lv, toc(env.now), name))

        global TEMP
        TEMP = int(name[5:])
        CALC[int(name[5:])] = env.now - CALC[int(name[5:])]


"""
(Type 3) Define customer behavior at first counter
"""
def customer3A(env, name, wl, ce1, ce2, ce3):

    with wl.lane.request() as request:

        if (env.now >= SIM_TIME):
            print("%s Not enough time! %s cancelled" % (ic_dang, name))
            env.exit()

        yield request
        yield env.process(wl.serve(name))
        print("%s (%s) %s is in waiting lane" % (ic_in, toc(env.now), name))

    # Start the actual drive-thru process
    print("%s (%s) %s goes into drive-thru counter" % (ic_go, toc(env.now), name))

    with ce1.employee.request() as request:

        if (env.now + TIME_COUNTER_A >= SIM_TIME):
            print("%s Not enough time! Assumed %s is quickly finished" % (ic_dang, name))
            yield env.timeout(0.5)
            env.exit()

        yield request

        CALC[int(name[5:])] = env.now
        yield env.process(ce1.serve(name))
        print("%s (%s) %s choose the order" % (ic_ask, toc(env.now), name))

        print("[2] (%s) %s will pay the order" % (toc(env.now), name))
        env.process(customer3B(env, name, ce1, ce2, ce3))

"""
(Type 3) Define customer behavior at second counter
"""
def customer3B(env, name, ce1, ce2, ce3):

    with ce2.employee.request() as request:

        if (env.now + TIME_COUNTER_B >= SIM_TIME):
            print("%s Not enough time! Assumed %s is quickly finished" % (ic_dang, name))
            yield env.timeout(0.5)
            env.exit()

        yield request

        yield env.process(ce2.serve(name))
        print("%s (%s) %s is paying the order" % (ic_mon, toc(env.now), name))

        print("[3] (%s) %s will take the order" % (toc(env.now), name))
        env.process(customer3C(env, name, ce1, ce2, ce3))

"""
(Type 3) Define customer behavior at third counter
"""
def customer3C(env, name, ce1, ce2, ce3):

    with ce3.employee.request() as request:

        if (env.now + TIME_COUNTER_C >= SIM_TIME):
            print("%s Not enough time! Assumed %s is quickly finished" % (ic_dang, name))
            yield env.timeout(0.5)
            env.exit()

        yield request

        yield env.process(ce3.serve(name))
        print("%s (%s) %s leaves" % (ic_lv, toc(env.now), name))

        global TEMP
        TEMP = int(name[5:])
        CALC[int(name[5:])] = env.now - CALC[int(name[5:])]

"""
Define detail of 2 counters setup environment
"""
def setup2(env, cr):
    # Create all counters
    wl = waitingLane(env)
    ce12 = counterFirstSecond(env)
    ce3 = counterThird(env)
    i = 0

    # Create more customers while the simulation is running
    while True:
        yield env.timeout(random.randint(*cr))
        i += 1
        env.process(customer2A(env, "Cust %d" % i, wl, ce12, ce3))

"""
Define detail of 3 counters setup environment
"""
def setup3(env, cr):
    # Create all counters
    wl = waitingLane(env)
    ce1 = counterFirst(env)
    ce2 = counterSecond(env)
    ce3 = counterThird(env)
    i = 0

    # Create more customers while the simulation is running
    while True:
        yield env.timeout(random.randint(*cr))
        i += 1
        env.process(customer3A(env, "Cust %d" % i, wl, ce1, ce2, ce3))

"""
Run the main program, execute via editor or terminal.
"""
if __name__ == "__main__":

    clear()
    print("""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>> Restaurant Queuing Model Simulation
>> Drive-Thru Fast Food Restaurant Design Model Evaluation
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>""")

    # Check if the number of counters is specified
    if len(sys.argv) < 2:
        nc = 3
    else:
        nc = int(sys.argv[1])

    # random.seed(RANDOM_SEED) # Helps reproducing the results

    # Has the environment in realtime (wall clock)
    # env = simpy.RealtimeEnvironment(factor=SIM_FACTOR)

    # Has the environment in manual step through
    env = simpy.Environment(initial_time=START)
    print("Environment created!")

    # Decide the counter model setup
    if nc == 2:
        env.process(setup2(env, CUSTOMER_RANGE))
    elif nc == 3:
        env.process(setup3(env, CUSTOMER_RANGE))

    print("Setup initialized!")

    print("Start simulation!")
    env.run(until=SIM_TIME)

    for i in range(TEMP+1):
        SUM_ALL += CALC[i]

    averageTimeService = SUM_ALL/(TEMP+1)
    servicePerSecond   = 1.00/(averageTimeService*60)
    servicePerMinute   = servicePerSecond*60

    print("The end!")
    print("%s Model: %d counters" % (ic_info, nc))
    print("%s Average time:       %.4f" % (ic_info, averageTimeService))
    print("%s Service per minute: %f" % (ic_info, servicePerMinute))

    # print(CALC)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote