Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 16, Problem 5PP
Program Plan Intro

  • Include required library files.
  • Define a class named “StackOverflowException”.
    • Inside the access specifier “public”,
      • Define a constructor to assign the message
      • Declare a parameterized constructor to assign “msg” to message.
      • Define a function “display” to return message.
    • Inside the access specifier “private”.
      • Declare a string variable “message”.
  • Define a class named “StackEmptyException”.
    • Inside the access specifier “public”,
      • Define a constructor to assign the message
      • Declare a parameterized constructor to assign “msg” to message.
      • Define a function “display” to return message.
    • Inside the access specifier “private”.
      • Declare a string variable “message”.
  • Define a class named “Stack”.
    • Declare an integer array and variable.
    • Inside the access specifier “public”,
      • Define a constructor to assign “-1” to “top”.
      • Define a “push()” function.
        • “try” block to check the top is equal to “3”.
          • The condition is true, throw exception.
          • Otherwise increment the top and the value is assigned to stack.
        • “catch” block to display the error message.
      •  Define a “pop()” function.
        • “try” block to check the top is equal to “-1”.
          • The condition is true, throw exception.
        • Otherwise decrement the top and return the value.
        • “catch” block to display the error message.
  • Define a “main()” function.
    • Create an object for class “Stack”.
    • Then check the “push()” and “pop()” function.

Blurred answer
Students have asked these similar questions
Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…
make a screen capture showing the StegExpose results
Which of the following is not one of the recommended criteria for strategic objectives? Multiple Choice   a) realistic   b) appropriate   c) sustainable   d) measurable
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning