Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 19, Problem 13PC
Program Plan Intro
Inventory Bin Queue
Program Plan:
InventoryItem.h:
- Include required header files
- Declare a class named “InventoryItem”. Inside the class,
- Inside “private” access specifier,
- Declare variables “serialNum”, “manufactDate”, and “lotNum”.
- Inside “public” access specifier,
- Give definition for default constructor.
- Give definition for overloaded constructor.
- Give mutator function “set_SerialNum ()” to set serial number.
- Give mutator function “set_ManufactDate ()” to set date.
- Give mutator function “set_LotNum ()” to set lot number.
- Give accessor function “get_SerialNum ()” that returns serial number.
- Give accessor function “get_ManufactDate ()” that returns date.
- Give accessor function “get_LotNum ()” that returns lot number.
- Inside “private” access specifier,
Dynqueue.h:
- Include required header files.
- Create template class
- Declare a class named “Dynqueue”. Inside the class,
- Inside the “private” access specifier,
- Create a structure named “QueueNode”.
- Create an object for the template
- Create a pointer named “next”.
- Create two pointers named “front” and “rear”.
- Create a structure named “QueueNode”.
- Inside “public” access specifier,
- Declare constructor and destructor.
- Declare the functions “enqueue ()”, “dequeue ()”, “isEmpty ()”, “isFull ()”, and “clear ()”.
- Inside the “private” access specifier,
- Declare template class.
- Give definition for the constructor.
- Assign the values.
- Declare template class.
- Give definition for the destructor.
- Call the function “clear ()”.
- Declare template class.
- Give function definition for “enqueue ()”.
- Make the pointer “newNode” as null.
- Assign “num” to newNode->value.
- Make newNode->next as null.
- Check whether the queue is empty using “isEmpty ()” function.
- If the condition is true then, assign newNode to “front” and “rear”.
- If the condition is not true then,
- Assign newNode to rear->next
- Assign newNode to “rear”.
- Increment the variable “numItems”.
- Declare template class.
- Give function definition for “dequeue ()”.
- Assign temp pointer as null.
- Check if the queue is empty using “isEmpty()” function.
- If the condition is true then print “The queue is empty”.
- If the condition is not true then,
- Assign the value of front to the variable “num”.
- Make front->next as “temp”.
- Delete the front value
- Make temp as front.
- Decrement the variable “numItems”.
- Declare template class.
- Give function definition for “isEmpty ()”.
- Assign “true” to a Boolean variable
- Check if “numItems” is true.
- If the condition is true then assign “false” to the variable.
- Return the Boolean variable.
- Declare template class.
- Give function definition for “clear ()”.
- Create an object for template.
- Dequeue values from queue till the queue becomes empty using “while” condition.
- Create an object for template.
Main.cpp:
- Include required header files
- Inside “main ()” function,
- Create a template for queue.
- Create an object for the class
- Declare variables “choice”, “serial”, and “mDate”.
- Print the menu to the user till the user enters corresponding menu number using “while” condition.
- Switch to case.
- Case1:
- Get the serial number and manufacturing date from the user.
- Push the object into the queue using the function “enqueue ()”.
- Case 2:
- Check if the queue is empty using “isEmpty ()” function.
- If the queue is not empty,
- Dequeue an element which is inserted first.
- Print the serial number and date that has been removed.
- Case 3:
- Exit
- Case1:
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
ASSUMING C LANGUAGE
True or False: You can have the data portion of a Linked List be a Struct containing a Linked List itself
Com
Please solve in Dart Programming Language
Traverse a collection with help of an iterator or list type object
Use a Queue as collection and also use the move next function to traverse
Solve it in the Dart. and don't forget to add the output
otherwise I willl downvote the solution
Stacks and Queues are called
data structures because their operations are specialized.
Chapter 19 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 19.1 - Describe what LIFO means.Ch. 19.1 - What is the difference between static and dynamic...Ch. 19.1 - What are the two primary stack operations?...Ch. 19.1 - What STL types does the STL stack container adapt?Ch. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - What is the difference between a static stack and...Ch. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - The STL stack is considered a container adapter....
Ch. 19 - What types may the STL stack be based on? By...Ch. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - The STL stack container is an adapter for the...Ch. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 21RQECh. 19 - Prob. 22RQECh. 19 - Prob. 23RQECh. 19 - Prob. 24RQECh. 19 - Prob. 25RQECh. 19 - Prob. 26RQECh. 19 - Write two different code segments that may be used...Ch. 19 - Prob. 28RQECh. 19 - Prob. 29RQECh. 19 - Prob. 30RQECh. 19 - Prob. 31RQECh. 19 - Prob. 32RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Dynamic String Stack Design a class that stores...Ch. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PCCh. 19 - Prob. 11PCCh. 19 - Inventory Bin Stack Design an inventory class that...Ch. 19 - Prob. 13PCCh. 19 - Prob. 14PCCh. 19 - Prob. 15PC
Knowledge Booster
Similar questions
- Queue Simulation Create a java program that will simulate Queue operations using 1-D array representation.Each operation is dependent from each other and it's carried out in the next question in a sequential order. Given: A Queue with 10 elements.arrow_forwardMultiple choice in data structures void stack::do(){ for(int i=0li<=topindex/2;i++){ T temp=entry[i]; entry[i]=entry[topindex-i-1]; entry[topindex-1-i]=temp;} } What is this method do? a. swap the first item with last item b. replace each item with next item value c. doesn't do any thing d. reverse the stackarrow_forwardA queue and a deque data structure are related concepts. Deque is an acronym meaning "double-ended queue." With a deque, you may insert, remove, or view from either end of the queue, which distinguishes it from the other two. Use arrays to implement a dequearrow_forward
- C++ data structure , queue amd linked list. write a function to remove the item that immediately comes before in item X from an integer queue if the item X is repeated then you should remove all the items immediately comes before it don't use different data structuresarrow_forwardC++ PROGRAM DATA STRUCTURES Write a function to swap nodes in a Doubly Linked list.arrow_forwardQueues Problem 4arrow_forward
- Multiple choice in data structures void doo(node<int>*root){ if(root !=0) { node<int>*p=root; while(root->next!=0) root=root->next; p->data=root->data; } What is this code do? a. swap the first item with the last item in the linked list b. set the first item in the linked list as the last item c. doesn't do anything because the root parameter is passed by value d. change the root item in the binary tree with the farthest leaf itemarrow_forwardC application controlled by menus to use array as a queue. Can you enqueue, dequeue, and play back data?arrow_forwardA data structure called a deque is closely related to a queue. Deque is an acronym meaning "double-ended queue." With a deque, you may insert, remove, or view from either end of the queue, which distinguishes it from the other two. Utilise arrays to implement a dequearrow_forward
- data structure Create a Java program using a Linked list by adding 5 nodes and then removing 1 node from the list. The node entries can be either Numbers (Int) or Characters (String).arrow_forwardProgramming Language C Note:No Need for Detailed Explanation. The Answer is Enough For Me.arrow_forwardjava data structurearrow_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