STARTING OUT WITH C++ REVEL >IA<
STARTING OUT WITH C++ REVEL >IA<
9th Edition
ISBN: 9780135853115
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
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.

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”.
    • Inside “public” access specifier,
      • Declare constructor and destructor.
      • Declare the functions “enqueue ()”, “dequeue ()”, “isEmpty ()”, “isFull ()”, and “clear ()”.
  • 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.

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

Blurred answer
Students have asked these similar questions
Q. Difference between Stack and Queue Data Structures. Write down key differences. Write some code snippets. Draw images with some examples. Show differences for operations like push/pop, add/remove, etc.
Refer to the operations below: Add (10 + 5) Add (4+8) Add (7*2) Add (90 – 3) Print list Print peek Remove an item from the list Print list 1.1 Implement the operations above into a Queue structure called q1.  1.2 Implement the operations above into a Stack structure called s1.
C++ Data Structures Write a program to implement two queues using doubly linked lists. User will enqueue values on first queue,when an element is dequeued from first queue it should automatically enqueue to second queue. From secondqueue user will dequeue this element explicitly.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education