STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
Chapter 18, Problem 7PC
Program Plan Intro

Queue Exceptions

Program Plan:

“main.cpp”:

  • This program features queues that can throw exceptions and print an appropriate error message and should terminate the program.
  • Include the required header files.
  • Prompt the user to enqueue 5 items.
  • Use of try – catch exceptional handling that returns error message and terminates the program if the queue overflows.
  • Prompt the user and allow user option to overflow the queue and dequeue the queue and print the values present in the queue.

“IntQueue.h”:

  • Include all the required header files.
  • Declare all the variables present in the queue along with their data types.
  • Declare all the function definition.
  • Declare the class underflow and overflow to check for exceptional handling in queue.

“IntQueue.cpp”:

  • Include all the required header files.
  • Call a constructor to create a queue and initialize its elements.
  • Initialize front and rear each to -1 and the number of elements initially present to 0.
  • A destructor is called to delete the queue array.
  • Define a queue function enqueue that inserts the value in variable num at the rear of the queue.
  • Define a queue function dequeue that deletes the value at the front of the queue, and copies it into variable.
  • Define a queue function isEmpty returns true if the queue is empty, and false if elements are present in the queue.
  • Define a Queue function is Full return true if queue is full and false if queue is not full.

Blurred answer
Students have asked these similar questions
Queue Exceptions: Modify the static queue class provided in our lecture as follows. Make the isFull and isEmpty member functions private. Define a queue overflow exception and modify enqueue so that it throws this exception when the queue runs out of space. Define a queue underflow exception and modify dequeue so that it throws this exception when the queue is empty. Rewrite the main program so that it catches overflow exceptions when they occur. The exception handler for queue overflow should print an appropriate error message and then terminate the program.
In C++ Please
C# Programing Language Given the code below 1.Change all of the low-level arrays in your program to use the appropriate C# collection class instead. Be sure to implement Deck as a Stack 2. Make sure that you use the correct type-safe generic designations throughout your program. 3.Write code that watches for that incorrect data and throws an appropriate exception if bad data is found.4. Write Properties instead of Getter and Setter methods. no lamdas, no delegates, no LINQ, no eventsGo Fish using System; namespace GoFish{public enum Suit { Clubs, Diamonds, Hearts, Spades };public enum Rank { Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }; // ----------------------------------------------------------------------------------------------------- public class Card{public Rank Rank { get; private set; }public Suit Suit { get; private set; } public Card(Suit suit, Rank rank){this.Suit = suit;this.Rank = rank;} public override string ToString(){return ("[" +…
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