Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 18, Problem 7PC
Program Plan Intro
Queue Exceptions
“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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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 ("[" +…
Chapter 18 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 18.3 - Describe what LIFO means.Ch. 18.3 - What is the difference between static and dynamic...Ch. 18.3 - What are the two primary stack operations?...Ch. 18.3 - What STL types does the STL stack container adapt?Ch. 18 - Prob. 1RQECh. 18 - Prob. 2RQECh. 18 - What is the difference between a static stack and...Ch. 18 - Prob. 4RQECh. 18 - The STL stack is considered a container adapter....Ch. 18 - What types may the STL stack be based on? By...
Ch. 18 - Prob. 7RQECh. 18 - Prob. 8RQECh. 18 - Prob. 9RQECh. 18 - Prob. 10RQECh. 18 - Prob. 11RQECh. 18 - Prob. 12RQECh. 18 - Prob. 13RQECh. 18 - Prob. 14RQECh. 18 - Prob. 15RQECh. 18 - Prob. 16RQECh. 18 - Prob. 17RQECh. 18 - Prob. 18RQECh. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Prob. 6PCCh. 18 - Prob. 7PCCh. 18 - Prob. 8PCCh. 18 - Prob. 14PCCh. 18 - Prob. 9PCCh. 18 - Prob. 10PCCh. 18 - Prob. 11PCCh. 18 - Prob. 12PCCh. 18 - Prob. 13PCCh. 18 - Prob. 15PC
Knowledge Booster
Similar questions
- stacks and queues. program must be able to handle all test cases without causing an exception Note that this problem does not require recursion to solve (though you can use that if you wish).arrow_forwardComputer Science For the basic ADT Queue operations, list all cases when a QueueException will be thrown. Each item listed should be no more than 10 words and ONLY in the form "exception name : cause of exception". Remember to use correct terminology or the answer will not be acceptedarrow_forwardC++ Code for a QueueThe program should features a Queue class with insert(), remove(), peek(),isFull(), isEmpty(), and size() member functions.The main() program creates a queue of five cells, inserts four items, removes threeitems, and inserts four more. The sixth insertion invokes the wraparound feature. All the items are then removed and displayed. The output looks like this:40 50 60 70 80arrow_forward
- This file has syntax and/or logical errors. Determine the problem and fix the program. // Employee's salary should not be negative // Include stack trace when exception occurs using System; using static System.Console; class FDebugEleven03 { static void Main() { Employee emp = new Employee(); try { emp.IdNum = 234; emp.Salary = -12; } catch (NegativeSalaryException e) { WriteLine(e.Message); WriteLine(e.StackTrace); } } } public class NegativeSalaryException : { private static string msg = "Employee salary is negative."; public NegativeSalaryException() : base(msg) { } } public class Employee { private int idNum; private double salary; public int IdNum { get return idNum; set idNum = value; } public double Salary { get {…arrow_forwardLanguage: C++ Note: Write both parts separately. Part a: Complete the above Priority Queue class. Write a driver to test it. Part b: Modify the above class to handle ‘N’ different priority levelsarrow_forwardfor c++ thank you Error Testing The DynIntStack and Dyn IntQueue classes shown in this chapter are abstract data types using a dynamic stack and dynamic queue, respectively. The classes do not cur- rently test for memory allocation errors. Modify the classes so they determine whether new nodes cannot be created by handling the bad_alloc exception. here is the extention.h file please use it #ifndef DYNINTQUEUE_H #define DYNINTQUEUE_H class DynIntQueue { private: // Structure for the queue nodes struct QueueNode { int value; // Value in a node QueueNode *next; // Pointer to the next node }; QueueNode *front; // The front of the queue QueueNode *rear; // The rear of the queue int numItems; // Number of items in the queue public: // Constructor DynIntQueue(); // Destructor ~DynIntQueue(); // Queue operations void enqueue(int); void dequeue(int &); bool isEmpty() const; bool isFull() const; void…arrow_forward
- In C, members (fields) of different structures can have the same name. True Falsearrow_forwardConcurrent Server Programming TITLE: Quiz Game In this assignment you are asked to write a phyton system to support an online math contest. The contest consists of answering the maximum quantity of sums in 30 seconds. This is done in a concurrent way, which means, that there are three participants answering at the same time. The participant with most correct answers WINS. The jury is responsible in starting up the server, after that they wait for the clients. When the three clients are connected, they must send the message: READY to the server. When the server receives the three READY from the clients, the contest starts. At the end of the program, the server must show the results .Execution (SERVER) - Please provide me the complete code and solution to arrive to the results below.python3 MathinikServer 192.168.1.2 Connected192.168.1.2 is Anne192.168.1.4 Connected192.168.1.4 is Billy192.168.1.3 Connected192.168.1.3 is MarkMark is READYAnne is READYBilly is READYStarting Contest…Contest…arrow_forwardc++ a Queue Class that allows users to push strings or integer values into it. For example, when running the following code: SpecialQueue Q; Q.push("Albert"); Q.push("Jose"); Q.push(123); Q.pop(); Q.pop(); Q.pop(); The output should be: Albert Jose 123 Submit a TEXT file that contains your class. By class, I mean everything EXCEPT your main function. DO NOT SUBMIT YOUR MAIN().arrow_forward
- 1 Implement a Queue Data Structure specifically to store integer data using a Singly Linked List. 2 The data members should be private. 3 You need to implement the following public functions: 4 1. Constructor: 5 It initialises the data members as required. 6 7 8 2. enqueue(data) : This function should take one argument of type integer. It enqueues the element into the queue and returns nothing. 3. dequeue(): It dequeues/removes the element from the front of the queue and in turn, returns the element being dequeued or removed. In case the queue is empty, it r 4. front (): 10 11 It returns the element being kept at the front of the queue. In case the queue is empty, it returns -1. 12 5. getSize(): 13 It returns the size of the queue at any given instance of time. 14 6. 1sEmpty(): 15 It returns a boolean value indicating whether the queue is empty or not. 16 Operations Performed on the Stack: 17 Query-1 (Denoted by an integer 1): Enqueues an integer data to the queue. 18 19 Query-2…arrow_forwardAssignment 05 PART 1 Queues - Note Part 1 is a separate deliverable: Write a class with a main method that uses a priority queue to store a list of prioritized chores. This is all the information that is provided. The rest is up to you. You may decide how to store your chores and how to store your priorities. YOU MUST WRITE your own Queue class – do not use the Java Library, Queue Class.arrow_forwardc++ code Screenshot and output is mustarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education