Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Evaluate the integral. 1 + sin x 1- sin x

Answered: 1 week ago

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago