Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

What are the advantages and disadvantages of BYOD?

Answered: 1 week ago

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago

Question

6. Conduct a cost-benefit analysis for a training program.

Answered: 1 week ago