1)Tuck+Gin

code format="cpp" //Created by Chan Tuck Ging 3S105


 * 1) include

using namespace std;

class stack{ protected: int top, full, empty; char data[5];

public:

stack{ top = -1; full = 0; empty = 1; };

~stack{ };

bool PUSH(char input){ cout << "Pushing \"" << input << "\"..." << endl; if (!full){ data[top+1] = input; top++; empty = 0; if (top==4){ full = 1; }               cout << "SUCCESS: \"" << input << "\" pushed." << endl << endl; return true; }           else{ cout << "ERROR: Stack is full." << endl << endl; return false; }       }

bool POP{ cout << "Popping..." << endl; if (!empty){ cout << "SUCCESS: \"" << data[top] << "\" popped." << endl << endl; data[top] = ' '; top--; full = 0; if (top==-1){ empty = 1; }               return true; }           else{ cout << "ERROR: Stack is empty." << endl << endl; return false; }       }

void display{ cout << endl; cout << "List of items stored: " << endl; for (int i=0; i<=4; i++){ cout << data[i] << endl; }           cout << endl; }

// MUST I put the bool ISEMPTY function? Rather useles here...       // Is there a more meaningful usage in more advanced programs?? };

int main{ stack object;       //create it        object.display; cout << "1) Removing an item from a STACK with no items" << endl;       object.POP;        cout << endl << "2) Adding items to a STACK that has 4 items" << endl; object.PUSH('a'); object.PUSH('b'); object.PUSH('c'); object.PUSH('d'); object.PUSH('e'); object.display; cout << endl << "3) Adding an item to a STACK that has 5 items" << endl;       object.PUSH('f');        cout << endl << "4) Showing that the items in the STACK are in LIFO order." << endl; object.POP; //popping e       object.POP; //popping d        object.POP; //popping c        object.POP; //popping b        object.POP; //popping a        object.POP; //for fun system("pause"); } code