Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Defieclass called SymbolBalance in the provided empty SymbolBalance.java file. Your SymbolBalance dlass should take a single command line argument. This argument should be the name
Defieclass called SymbolBalance in the provided empty SymbolBalance.java file. Your SymbolBalance dlass should take a single command line argument. This argument should be the name of another java file. Read in the file and check to make sure that all (s,)'s, []'s," "s, and*'s are properly balanced. Make sure to ignore characters within literal strings and comment blocks. You do not need to handle single line comments (those that start with //), literal characters (things in single quotes), or the diamond operator There are a number of error cases: . The file ends with one or mare pening symbals missing their corresponding closing symbols. There is a closing symbol without an opening symbol. There is a mismatch between closing and opening symbols (for example: { [ } ] . Your program should output whether or not the symbols are all appropriately balanced. If they are not, indicate which error condition ocourred and what symbol type caused the problem You will need to write your own stack class for this. It should be generic (in this particular case you wll be pushing Character objects on it, but it should be capable of handling any object refererice). Call your stack class: MyStack java.You should use ava.utn LinkedList as an instance variable in your MyStack class, but in the implernentation of your stack methods, you are only allowed to use its basic list operations, not the stack operations themselves (that is, do not use Linked List's native push and pop methods). Your stack should implenent the following methods: puolic void push(AnyType x public AnyType pop() puaLic AnyType pook() puolic boolean stroty() epuslic int size) Define this class in the provided empty MyStack.java file. Here is an example. You are given a file with the fellowing contents public static final void nain(Strinelares) ( Systen,out,printin("Hello."i You would run your program like this: java SynolRalance Test java and the output should be something like: unbalanced! Synto1 } is fli snatched We have provided you with a number of Test inputs in the sub-folder TestFiles. We will use our own test files to grade your performance on all conditions-those files will be released after the assignment is due. Defieclass called SymbolBalance in the provided empty SymbolBalance.java file. Your SymbolBalance dlass should take a single command line argument. This argument should be the name of another java file. Read in the file and check to make sure that all (s,)'s, []'s," "s, and*'s are properly balanced. Make sure to ignore characters within literal strings and comment blocks. You do not need to handle single line comments (those that start with //), literal characters (things in single quotes), or the diamond operator There are a number of error cases: . The file ends with one or mare pening symbals missing their corresponding closing symbols. There is a closing symbol without an opening symbol. There is a mismatch between closing and opening symbols (for example: { [ } ] . Your program should output whether or not the symbols are all appropriately balanced. If they are not, indicate which error condition ocourred and what symbol type caused the problem You will need to write your own stack class for this. It should be generic (in this particular case you wll be pushing Character objects on it, but it should be capable of handling any object refererice). Call your stack class: MyStack java.You should use ava.utn LinkedList as an instance variable in your MyStack class, but in the implernentation of your stack methods, you are only allowed to use its basic list operations, not the stack operations themselves (that is, do not use Linked List's native push and pop methods). Your stack should implenent the following methods: puolic void push(AnyType x public AnyType pop() puaLic AnyType pook() puolic boolean stroty() epuslic int size) Define this class in the provided empty MyStack.java file. Here is an example. You are given a file with the fellowing contents public static final void nain(Strinelares) ( Systen,out,printin("Hello."i You would run your program like this: java SynolRalance Test java and the output should be something like: unbalanced! Synto1 } is fli snatched We have provided you with a number of Test inputs in the sub-folder TestFiles. We will use our own test files to grade your performance on all conditions-those files will be released after the assignment is due
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started