# Dynamic stack MathStack Solved

20.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` zip` solution files instantly, after Payment

## Description

5/5 - (7 votes)

Carefully review Program 18-2 in your textbook,Â MathStackÂ (starting on page 1071 in the 8th edition and on page 1051 in the 7th edition).Â This is aÂ staticÂ stack, meaning that the size of the stack is set at the beginning of the program (see line 11, page 1073):Â MathStack stack(5).

modify this program as follows:

1.Â Implement it as a dynamic stack (do not use a static stack as it is designed in the book).

2.Â Add functionality for Mult, Div, Pop, and Display.

Make looping menu-driven program to demonstrateÂ your code so that the user has the choice of:

1.Â Push (an integer onto the stack)

2.Â Pop (an integer off the stack)

3.Â Add (the top two values in the stack and replace those two values with the sum)

4.Â Subtract (the top two values on the stack and replace those two values with the difference)

5.Â MultÂ (same as above)

6.Â Div (same as above but check for div by 0)

7.Â Display Stack

8.Â End

Make sure you have both high and lower-level validation.Â Watch out for division by 0 and not having enough integers on your stack to do the operation.Â Make sure to only allow integers on your stack.Â I would suggest that you implement low-level errors the way we did in Chapter 17 (by returning a status flag, -1 if there’s an issue).Â Finally, make sure main() is properly organized into functions and don’t forget to document your code including your class.

• dynamic-stack.zip