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
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