18)Yong+Keat

code format="cpp" using namespace std;
 * 1) include

class stack{ protected: char stack1[5]; int top; bool FULL, EMPTY;

public: stack{ int j; for (j=0;j<=5;j++) { stack1[j]=' '; } top=0;};

bool PUSH(char ch) { cout << "Number(s) Stored: " << top+1 << endl; stack1[top] = ch; top++; }

char POP{ top--; cout << stack1[top]; stack1[top] = ' '; return stack1[top]; }

bool IS_EMPTY { if (top==0) { cout << "Stack is EMPTY."; return 1; } else return 0; }

bool IS_FULL { if (top==5) { cout << "Stack is FULL."; return 1; } }

void display { int k; for (k=0;k<=5;k++){ cout << stack1[k]; } }

};

int main { stack stackobject1; char inputchar; char random[4] = {}; int i,x=1; char pp; bool start=true; stackobject1.display;

while(start==true) { cout << endl << "Type O for POP/U for PUSH/D for display stack."; cin >> pp; if (pp=='O') { if (stackobject1.IS_EMPTY==1){ cout << endl << "Stack is empty."; } else {cout << "Object popped: "; stackobject1.POP; } } else if (pp=='U'){ cout << endl << "Input 1 char: "; cin >> inputchar; if(stackobject1.IS_FULL==1){ cout << endl << "Stack is full."; } else {stackobject1.PUSH(inputchar);cout << "Object added." << endl;} } else if (pp=='D') { stackobject1.display; } else break;

cout << endl << "Again? (Type 1 for yes, 0 for no)"; cin>>start; if (start==false) { break; } } cout << endl << "END."; system("pause");

} code