Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please code this in c++, Please read all the instructions do not code randomly!

ID: 3597490 • Letter: P

Question

Please code this in c++, Please read all the instructions do not code randomly!

----------------------------------------------------------------------------

PROGRAM SPECIFICATION

For the assignment, we are going to design a class that stores strings on a dynamic stack. The strings should not be fixed in length. The stack is implemented as a struct type std::string.

For this assignment, you will need to provide these public member functions that perform the following tasks:

A) push Member function push pushes the argument onto the stack.

B) pop This member function pop pops the value at the top of the stack off.

C)isEmpty Member function isEmpty returns true if the stack is empty, or false otherwise.

Make certain that your implementation is placed out on the heap.

You will find the original driver program under the same assignment repository, called main (for string stack). Modify the driver to include your implementation and member function files, and then make sure your program can execute the test cases successfully.

OUTPUT Of the program when done should look like this:

Explanation / Answer

#include<bits/stdc++.h>

using namespace std;

class Stack

{

int top=-1;

int capacity=100;

String *stack= new String[capacity];

public:

void isEmpty()

{

if(this.top==-1)

{

return true;}

else return false;

}

void push(String str)

{

cout<<"pushing "<<str<<endl;

if(this.top==capacity)

{

cout<<"overflow"<<endl;

}

else

{

this.top++;

this.stack[this.top]= str;

}

}

String pop()

{

cout<<"Attempting to pop Again..."<<endl;

if(isEmpty())

{

cout<<"the stack is Empty"<<endl;

}

else

{

cout<<this.stack[this.top]<<endl;

top--;

}

}

}

int main()

{

Stack stk= new Stack();

stk.push("one");

stk.push("two");

stk.push("three");

stk.pop();

stk.pop();

stk.pop();

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote