2)Joshua+Foo

code format="cpp" //LA MISSION by Joshua Foo 3S2-05 using namespace std;
 * 1) include

class STACK { protected: int top; char ARRAY[5]; bool EMPTY, FULL; public: STACK {top = 0; EMPTY = true; FULL = false;};//top is the number of chars ~STACK{}; bool PUSH(char e) { if(!FULL) {//If STACK is not full, it can be pushed ARRAY[top] = e;                      cout << e << " has been pushed successfully!\n"; if(top == 4) {//If there are already 4 characters and you wish to push, STACK will become full. FULL = true; }                      top++;//Number of characters increase EMPTY = false;//If STACK is empty and is pushed, it will not remain empty.

}           else {//If STACK is full cout << "STACK is FULL and " << e << " cannot be pushed!\n";//Return display }      }      char POP { if(!EMPTY) {//If STACK is not empty, it can be popped if(top == 1) {//If there is only 1 character left and it is popped, STACK will become empty. EMPTY = true; }                     cout << ARRAY[top-1] << " has been popped successfully!\n";//Return display ARRAY[top-1] = ' ';//Blanking the popped character top--;//Number of characters decrease FULL = false;//If STACK is full and it is popped, it will not remain full. }          else {//If STACK is empty cout << "STACK is EMPTY and cannot be popped!\n";//Return display }     }

//Remember to return the character that has been pop so the prog is able to use it in code

bool ISEMPTY {//to retrieve EMPTY bool return EMPTY; }     bool ISFULL {//to retrieve FULL bool return FULL; } };

int main { STACK DEMO; //(1)Stack is empty; attempt to pop. cout << "(1) STACK is empty. Attempt to pop:\n"; DEMO.POP; cout << "--\n"; //(2)Attempt to add more than 1 item when stack has 4 items. for (int i=0; i<4; i++) {//Adding 4 characters A,B,C,D to STACK. DEMO.PUSH(char(i+65)); }   cout << "(2) STACK has 4 characters now. Attempt to push twice:\n"; cout << "First: "; DEMO.PUSH('E'); cout << "Second: "; DEMO.PUSH('F'); cout << "--\n"; //(3) Stack has 5 characters A,B,C,D,E; attempt to push. cout << "(3) STACK has 5 characters already and is FULL. Attempt to push:\n"; DEMO.PUSH('F'); cout << "--\n"; //(4) Removing 5 items characters A,B,C,D,E in LIFO order. cout << "(4) STACK has 5 characters A,B,C,D,E with E on top and A below. All 5 will be popped top first:\n"; while (!DEMO.ISEMPTY) {//When STACK is not empty, it can be popped. DEMO.POP; }   system("pause"); } code