Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python plz 16.28 Lab 9D: Manage a queue Overview Manage the queue at the Secretary of State office Objectives To understand how to use

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

in python plz

16.28 Lab 9D: Manage a queue Overview Manage the queue at the Secretary of State office Objectives To understand how to use a menu of possible actions repeatedly with a sentinel loop, understand how to add and remove elements of a list, and think about how to create a more complicated program by breaking it into manageable pieces. Description Imagine that we are creating an app to manage the queue at the Secretary of State office. As customers arrive, they are added to the end of the queue. When workers are available to help the customers, they will call the name of the first person in the queue, and remove them from the queue. Another option for the app is to print out the entire queue so customers can see where they stand. The menu options are (1) Add a customer to the queue (2) Serve the customer (3) Print out the queue (4) Quit the application. At the beginning of the day, the queue is empty. When a customer is added to the queue, you will have to prompt for the customer's name. When a customer is served, you should print the message "Now serving customer Jon." if the first name in the queue is Jon, so Jon is called to the counter and removed from the queue. If the app user enters anything besides 1, 2, 3, or '4', you should print out the message "Unknown menu option." and display the menu again. When the user enters the option 4, the program should just exit without printing anything. NOTE: You should think about handling the case where the user tries to serve a customer when there are no customers in the queue. If that happens, you should print out the message "No customers to serve.". Get everything else working first, then work on that part. Following is an example run of what the program should look like after 'jon', 'ben', and 'anika' have already been added to the queue: (1) Add a customer to the queue. (2) Serve customer. (3) Print queue. (4) Exit. What is the customer's name? bridget (1) Add a customer to the queue. (2) Serve customer. (3) Print queue. (4) Exit. ['jon', 'ben', 'anika', 'bridget'] (1) Add a customer to the queue. (2) Serve customer. (3) Print queue. (4) Exit. Now serving customer jon. (1) Add a customer to the queue. (2) Serve customer. (3) Print queue. (4) Exit. ['ben', 'anika', 'bridget'] (1) Add a customer to the queue. (2) Serve customer. (3) Print queue. (4) Exit. To attack a problem such as this one, you need to think about the structure of the program without getting bogged down in the details at first. It is a good strategy to get the menu and loop structure working first. To do this, for each menu option you can simply print out a statement like "add customer to queue", "print the queue" etc as the user enters the appropriate option. Then once you know that part is all working correctly, substitute the print statements with the code that will actually manipulate the queue. Look at zyDE 9.6.1 for inspiration, and make changes as needed for this problem. If you ask the TAs for help on this lab, the first thing they will do is ask to see your thought processes. They will not help you with any code until you can describe your process to them. And you should not write any code before you understand how the structure of the program will work and have written down the steps. You can write down your thought processes on paper, or in the form of comments in a .py file that you will then add code to around the comments. LAB 16.28.1: Lab 9D: Manage a queue 0/350 main.py Load default template... 1 # initialize the queue to be empty Hemt menu = ('(1) Add a customer to the queue. In' (2) Serve customer. In (3) Print queue. In (4) Exit. ') 9 # print out the menu and get the user's input 10 user_input = input (menu).strip().lower() 0019 12 # keep asking for the user's choice until they choose option 4. 14 # INSERT CODE FOR THE APPROPRIATE WHILE CONDITION BELOW: 15 # while user does not want to exit: # check each option and do the appropriate thing for each # INSERT CODE FOR ALL THE MENU OPTIONS HERE main.py Load default template... 4 menu = ('(1) Add a customer to the queue. In (2) Serve customer. ' (3) Print queue. In '(4) Exit. ') 9 # print out the menu and get the user's input 10 user_input = input (menu).strip().lower() 12 # keep asking for the user's choice until they choose option 4. 14 # INSERT CODE FOR THE APPROPRIATE WHILE CONDITION BELOW: 15 # while user does not want to exit: # check each option and do the appropriate thing for each 16 # INSERT CODE FOR ALL THE MENU OPTIONS HERE # print the menu again and get the next command user_input = input (menu).strip().lower()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago