20)Shao+Yun

code format="cpp-qt" /*By: TAN SHAO YUN 3S228*/

using namespace std;
 * 1) include

class STACK{ private: int top; char CHAR[5]; bool FULL; bool EMPTY; char highest; public: STACK{ //constructor top=0; FULL=false; EMPTY=true; }

~STACK{ /*destructor*/ };

char PUSH(char x){ if(!FULL){ CHAR[top]=x; highest=CHAR[top]; top++; EMPTY=false; ISFULL; for (int i=0; i<top; i++){ if(i==top-1){ cout<<CHAR[i]<<".\n"; }else{ cout<<CHAR[i]<<","; }                   }                    return highest; }else{ ISFULL; cout<<"Stack FULL! Must POP first!\n"; return false; }            }

char POP{ if(!EMPTY){ highest=CHAR[top-1]; EMPTY=true; ISEMPTY; top--; cout<<"Popped!\n"; }else{ cout<<"Stack EMPTY! Must PUSH first!\n"; }            }

bool ISEMPTY{ if(top==0){ FULL=true; }else{ FULL=false; }            }

bool ISFULL{ if(top==5){ FULL=true; EMPTY=false; return true; }else{ FULL=false; return false; }            } };

int main{ int choice; char chose; STACK stack; do{ cout<<"\n\n"; cout<<"What would you like to do?\n"; cout<<"1. Push\n"; cout<<"2. Pop\n"; cout<<"or exit?\n"; cout<<"Choice: "; cin>>choice; cout<<"\n\n"; switch(choice){ case 1: cout<<"1. Push\n"; cout<<"Character to push: "; cin>>chose; stack.PUSH(chose); break; case 2: cout<<"2. Pop\nPopping...\n"; stack.POP; break; }   }while( choice==1 || choice==2 ); cout<<"Exiting.\n"; system("PAUSE"); return 0; }

code