Stack with error protection
Implement the "stack" data structure. Write a program containing the description and the modeling of the stack, implementing all the methods specified below. The program reads a sequence of commands and, depending on the command, performs one or another operation. After each command is executed, the program should output one line. Possible commands for the program:
push n - Add number n into the stack (n is non-negative). Program must print ok.
pop - Remove from the stack the last element. The program must print its value.
back - The program must print the value of the last element without removing it out of the stack.
size - The program must print the number of elements in the stack.
clear - The program must clean the stack and print ok.
exit - The program must print bye and terminate.
Before executing operations back and pop the program must check whether the stack contains at least one element. If the input data contains operation back or pop, but the stack is empty, instead of the number print the string error.
Input
Each line contains one command.
Output
For each command print in separate line the corresponding result.