Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 13, Problem 8PP
Program Plan Intro
Creation of program to simulate customer arrivals at motor vehicles department
Program Plan:
- Define a class “Queue” to denote methods and operations required for queue.
- Declare variables that are required for program.
- Define a constructor “Queue()” and assign values.
- Define a method “Enqueue()” to insert values into a queue.
- Define a method “Dequeue()” to remove value from a queue.
- Define a method “Front()” to return front element of queue.
- Define a method “Size()” to return size of queue.
- Define a method “isEmpty()” to check whether queue is empty or not.
- Define a main method
- Call method “Enqueue()” to insert values into a queue.
- Call method “Dequeue()” to remove value from a queue.
- Call method “Front()” to return front element of queue.
- Call method “Size()” to return size of queue.
- Call method “isEmpty()” to check whether queue is empty or not.
- Loop until the user needs to compute result.
- To simulate customer arrival call “Enqueue()” method with required parameters.
- To help next customer call “Dequeue()” method.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
I would like to implement a queue as a class with a linked list. This queue Is used to help the class print job in displaying things like:
a confirmation of the job request received and the status ( denied/accepted) along with the details such as a tracking number, position in the queue( if accepted), reason for denial (if denied), etc.
These classes will be used in a menu-driven application that has the following options:
request a print job
ask for the job name; the name may have blank spaces and consist of alphanumeric characters only, must start with a letter
display a confirmation of the job request received and the status ( denied/accepted) along with the details such as a tracking number, position in the queue( if accepted), reason for denial (if denied), etc
execute a print job (remove from the queue )
display a confirmation along with the tracking number, the name of the print job, and the number of print jobs currently in the queue
display number of print jobs…
Imagine a ballroom with two kinds of dancers: leaders and followers. Dancers of both kinds wait in two separate queues before entering the dance floor. When a leader arrives, it checks to see if there is a follower waiting. If so, they can both proceed. Otherwise it waits. Similarly, when a follower arrives, it checks for a leader and either proceeds or waits, accordingly. Make sure that the next pair of leader/follower may dance only after the previous pair is done.Write the pseudocode for leaders and followers that enforces these constraints.
QUESTION 9
Write a complete Java program to implement a QUEUE in a bank using LinkedList class as follows:
• Provide the menu as shown below; use an infinite loop; stop when user opts 4.
1. Add a customer
2. Remove a customer
3. Show the queue
4. Exit
• Add a customer should add an int number at the end of queue using the method addLast().
• Remove a customer should delete the int from front using the method removeFirst().
Show the queue should display the numbers in queue using the method System.out.printIn().
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac).
Chapter 13 Solutions
Problem Solving with C++ (10th Edition)
Ch. 13.1 - Suppose your program contains the following type...Ch. 13.1 - Suppose that your program contains the type...Ch. 13.1 - Prob. 3STECh. 13.1 - Prob. 4STECh. 13.1 - Prob. 5STECh. 13.1 - Prob. 6STECh. 13.1 - Prob. 7STECh. 13.1 - Suppose your program contains type definitions and...Ch. 13.1 - Prob. 9STECh. 13.2 - Prob. 10STE
Ch. 13.2 - Prob. 11STECh. 13.2 - Prob. 12STECh. 13.2 - Prob. 13STECh. 13 - The following program creates a linked list with...Ch. 13 - Re-do Practice Program 1, but instead of a struct,...Ch. 13 - Write a void function that takes a linked list of...Ch. 13 - Write a function called mergeLists that takes two...Ch. 13 - In this project you will redo Programming Project...Ch. 13 - A harder version of Programming Project 4 would be...Ch. 13 - Prob. 6PPCh. 13 - Prob. 8PPCh. 13 - Prob. 9PPCh. 13 - Prob. 10PP
Knowledge Booster
Similar questions
- The implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forwardJavaarrow_forwardAn airport has a runway for airplanes landing and taking off. When the runway is busy, airplanes wishing to take off or land have to wait. Landing airplanes get priority, and if the runway is available, it can be used. Implement a Java class, Airport.java, for this simulation, using two appropriate lists, one for the airplanes waiting to take off and one for those waiting to land. Note that the data structures you select for the two lists must be suitable for this purpose. For instance, the sooner an airplane comes for landing, the sooner it will land. Also, you must keep the record of all the airplanes that have already landed or taken off in one single list, to print out the activity log whenever asked, such that the sooner an airplane landed, the later it shows in the printout. To get a clear idea, please have a close look at the expected outputs of the execution of the tester class provided. The user enters the following commands: (The user entry has already been done in the tester…arrow_forward
- In Java In the real world, you will often be tasked with understanding and improving another person’sinelegant, hard-to-understand code. This project provides practice for that type of work.The given program, shown below, implements a circular-array queue. A queue is a British term for aline of people waiting to be served. A queue can also refer to any line of items where the item at thefront of the queue is served next, and new items are added at the rear of the queue. Informationtransmission systems, like the Internet, have lots of queues, where messages in transit are temporarilystalled at some intermediate system node, waiting to get into the next available time slot on the next legof their journey. A queue’s length is the total number of people or items currently waiting. When thenext item is served, that shortens the queue by one. When another person arrives, that lengthens thequeue by one. A queue’s capacity is the maximum number of items that can fit in the line at one time.If…arrow_forwardYou want to buy a ticket for a well-known concert which is happening in your city. But the number of tickets available is limited. Hence the sponsors of the concert decided to sell tickets to customers based on some priority. A queue is maintained for buying the tickets and every person is attached with a priority (an integer, 1 being the lowest priority). The tickets are sold in the following manner - 1. The first person (pi) in the queue requests for the ticket. 2. If there is another person present in the queue who has higher priority than pi, then ask pi to move at end of the queue without giving him the ticket. 3. Otherwise, give him the ticket (and don't make him stand in queue again). Giving a ticket to a person takes exactly 1 minute and it takes no time for removing and adding a person to the queue. And you can assume that no new person joins the queue. Given a list of priorities of N persons standing in the queue and the index of your priority (indexing starts from 0). Find…arrow_forwardFor the Assignment 5 (Part 2), Routes v.2 at the end of this module you will create a Route class that has a member a "bag" of Leg objects. The bag is to use a vector of pointers, but since all the objects in the bag are to be Leg s, it's okay to use Leg* instead of void* in the bag's declaration. You wrote its first constructor in a previous exercise. Now write a second one. (You may refer to the Assignment page to refer to the completed class declarations of Leg and Route classes). Assume that class Leg has data member C strings const char* const beginCity; and const char* const endCity; that are available to Route by a friend relationship. Write a constructor function for a Route class that takes exactly two parameters: a constant Route object reference to an already-existing Route , and a constant Leg object reference to be appended to the end of that Route to form the new Route . Here's the algorithm: Copy the first parameter's bag into the host object's bag. If the endCity of…arrow_forward
- Define a class called MyLinkedQueue containing two data field: head and tail. Create constructors, setters and getters as appropriate. Define an inner class called QueueNode inside MyLinkedQueue containing necessary data fields, and constructors, to make sure the queue can move back and forth. Implement the poll and offer methods for the MyLinkedQueue class. Implement the isPalindrome method to the MyLinkedQueue class to check if the queue going forward is identical to the queue going backwards. For example, Queue {1,2,3,2,1} is Palindrome. Given an ArrayList of integers, return indices of the two numbers such that they add up to a specific target. For example, Given nums = [2, 7, 11, 15], target=9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0,1].arrow_forwardFor this assignment, you will be programming an airport simulator. The airport has one runway, and a plane can either be taking off or landing on it at any given unit of time. There will be a queue of planes waiting to take off and a priority queue of planes waiting to land. Your simulator will share some similarities to the movie theater simulator from the lecture notes (and the code is posted on Canvas). To make this project much simpler, I recommend studying that code and basing your code off of it. When the user starts the simulation, let them decide the % chance that a plane will show up to land and the % chance that a plane will show up to take off each clock tick. Let them also decide how many clock ticks to run the simulation for. Recall that the simulation should run inside a for loop. Each loop iteration represents one unit of time (or clock tick). In each clock tick, you need to: Randomly decide if a plane should join the take-off queue, based on the percentage provided by…arrow_forwardA group of researchers hired you to develop a system to manage the execution of their computing jobs (tasks) in a piece of equipment. This cquipment can only execute one job at a time. Thus, you need to create a Queue class to queue jobs. The queue can be associated with one of the following strategies for selecting jobs: First In First Out (FIFO). Lowest First (LF), and Last In First Out (LIFO). Use the Strategy design pattern for representing these strategies and their association to Queue. Draw a UML diagramarrow_forward
- Java Given main() in the Inventory class, define an insertAtFront() method in the InventoryNode class that inserts items at the front of a linked list (after the dummy head node).arrow_forward7arrow_forwardWrite a program to maintain a list of items as a circular queue, which is implemented using an array. Simulate insertions and deletions to the queue and display a graphical representation of the queue after every operation.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning