Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Vucutives To understand how to use a menu of possible actions repeatedly with a sentinel loop, understand how to add and remove elements of a

image text in transcribedimage text in transcribed

Vucutives 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. (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. ACTIVITY 16.28.1: Lab 9D: Manage a queue 0/35 main.py Load default template... 1 # initialize the queue to be empty 4 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() 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 18 # INSERT CODE FOR ALL THE MENU OPTIONS HERE print the menu again and get the next command Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the programs output in the second box Predefine program input (optional) If you'd like to predefine your inputs, provide them here

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

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions