Reference no: EM131145363
Write a java program for the following, must be two seperate methods(main and the stack class using generics).
The purpose of the stack is to check an expression involving parentheses, braces, & brackets and determine whether they are balanced
Create a separate class for your stack and implement three stack related methods (push(), pop(), and peek() only) in it.
YOU ARE NOT ALLOWED TO USE STACK CLASS FROM JAVA API.
You need to build your own stack class. The class should be reusable, that is, do not make it type specific. Use of Generic could be helpful. You can use this stack class in future to solve stack-related problems involving any data type.
Safely assign relatively large size (may be 1000) for the stack. Once the stack class is built use the class to solve the problem mentioned above. This should be a separate .java file containing the main() method.
The main() method is responsible to capture the input (file name with .java extension), parse it, use the stack (as defined in the other file), and then produce the output displaying a message showing whether the expression is balanced (parentheses, braces, and brackets) or not.