6)Sean+Lee

Note: I did not make use of the variables 'FULL' and 'EMPTY' in the private class attributes.

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

class stack { private: int top; char array[5];

public: stack{ top = 0; int a = 0; while (a<5) { array[a] = ' '; a++; }      }      ~stack{};

bool push(char x) { array[top] = x;          top++; };

char pop { top--; array[top] = ' '; };

bool is_empty { if (top == 0) return 1; else return 0; };

bool is_full { if (top >= 5) return 1; else return 0; };

void Display { cout << "\nTop\n"; int i = 4; while (i >= 0) { cout << "[" << array[i] << "]\n"; i--; };          cout << "Btm"; }; };

int main { stack s;   string cmd, in; bool cont = 1, error = 1; int i = 0;

cout << "LIFO stack [Version 1.0.0].\n"; cout << "Type '/?' for help.\n";

while (cont) { error = 1; cout << "\n_root@: "; cin >> cmd; for (i=0; i> in; if (s.is_full) { cout << "\nSystem Error 5 has occured.\n"; cout << "The stack is full. \n"; } else if (in.length>1) { cout << "\nSystem Error 5 has occured.\n"; cout << "Please enter only one character.\n"; in.clear; } else { s.push(in[0]); cout << "\nOperation successful.\n"; };          error = 0; }

else if (cmd == "pop") { if (s.is_empty) { cout << "\nSystem Error 5 has occured.\n"; cout << "The stack is empty. \n"; } else { s.pop; cout << "\nOperation successful. \n"; };          error = 0; }

else if (cmd == "disp") { s.Display; cout << "\n"; error = 0; }

else if (cmd == "exit") { cont = 0; error = 0; }

else if (cmd == "/?") { cout << "\nLIFO stack help - Commands:\n\n"; cout << "DISP\n- Displays the stack.\n"; cout << "POP\n- Removes the top element from the stack.\n"; cout << "PUSH [*]\n- Adds the char denoted by * to the stack.\n"; cout << "- Example: 'PUSH e' adds the char 'e' to the stack.\n"; cout << "EXIT\n- Exits the program.\n"; cout << "\nNote: Stack limit is 5.\n"; error = 0; }

else if (error) { cout << "\n'" << cmd << "' is not recognised as an internal or external command,\n"; cout << "operable program or batch file.\n"; }   }    return 0; }

code