Question: I need help with Java program HW. I figured out the {}, () and [] but am struggling with /* */ and because
I need help with Java program HW. I figured out the {}, () and [] but am struggling with /* */ and " " because you have to ignore symbols within them by not pushing onto the stack.
Tasks: read in a file to check to make sure that all { }s, ( )'s, [ ]'s, " "s, and /* */s are properly balanced. Ignore characters within literal strings and comment blocks. Use a stack data structure to test for balanced or unbalanced result. Ignore single comments //, < >, and literal characters like 'dff'
Account for these errors:
The file ends with one or more opening symbols missing their corresponding closing symbols.
Closing symbol without an opening symbol.
Mismatch between closing and opening symbols (for example: { [ } ] ).
If the symbols are balanced, output that the symbols are balanced
If not balanced, output which error occurred and what symbol.
For example if the file contains: char { x = ['a', 'b', 'c', 'd']; the output should be like: Symbol { is mismatched.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
