Question: DO NOT USE any of the STL (including the vector type) in your Stack. For this lab, you should write a C++ program that creates

DO NOT USE any of the STL (including the vector type) in your Stack.

For this lab, you should write a C++ program that creates an integer stack named doubleStack using the dynamic array implementation. Use typedef to indicate the data type of the elements in the stack. Set the default type as int, but the code should remain to work if the typedef is changed to float.

Set the initial size of the stack to 5. The program should support operations push(), pop(), and print(). You should NOT create a new struct or class for this lab.

First, ask the user for a positive value to push to the stack. Once the stack has one or more elements, every push operation adds a value that is the current top value times two (top x 2). Ask if the user wants to push, pop, or quit with the following line.

cout << "Do you want to push (p), pop (o), or quit (q)?" << endl;

Allow the user to push or pop as many elements as they wish. When the stack is full OR when the user wants to stop, print all the elements in doubleStack and end the program. Please note that youll be using a dynamic array in this lab. Make sure that your code meets all the requirements associated with dynamic memory allocation.

Execution example

Welcome! Please enter a positive value: 2

Do you want to push (p), pop (o), or quit (q)? p inserted 4

Current stack: 2, 4

Do you want to push (p), pop (o), or quit (q)? o

The popped value is 4

Do you want to push (p), pop (o), or quit (q)? o

The popped value is 2

Do you want to push (p), pop (o), or quit (q)? o

Nothing to pop

Do you want to push (p), pop (o), or quit (q)? p

Please enter a positive value: 3

inserted 3

Current stack: 3

Do you want to push (p), pop (o), or quit (q)? p

inserted 6

Current stack: 3, 6

Do you want to push (p), pop (o), or quit (q)? p

inserted 12

Current stack: 3, 6, 12

Do you want to push (p), pop (o), or quit (q)? p

inserted 24

Current stack: 3, 6, 12, 24

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!