Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java application to open any text file, then to read the entire file character by character and use a stack of characters to

Write a Java application to open any text file, then to read the entire file character by character and use a stack of characters to either output an error message if parens, brackets and curly braces are not properly nested, or a message stating that the file is correct if all of those symbols are properly nested. The basic idea is to push left parens, left brackets and left curly braces onto the stack, then to pop the stack when a right paren, right bracket or right curly brace is encountered and make sure the two symbols match.

Be sure to output appropriate, different, error messages if the left symbol from the stack does not match the right one, if the stack is empty when you need to pop it, and if the stack is not empty when the input is complete.

Note that a Java program that compiles will be correct if there are no parens, brackets or braces in quotes or comments

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_step_2

Step: 3

blur-text-image_step3

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

Students also viewed these Databases questions

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago