Question
JAVA -- Using the static method public static boolean containsMismatchedParentheses(List source){...}, implement a mismatched parentheses checker that highlights mismatched parentheses. This list of strings source
JAVA --
Using the static method public static boolean containsMismatchedParentheses(List
If mismatched parentheses are discovered while processing the lines of the file, an error message should be printed to standard out stating one of the following:
System.out.printf(Error. Closing } encountered. %s popped off the stack. , stack.pop())
System.out.printf(Error. Closing ] encountered. %s popped off the stack. , stack.pop())
System.out.printf(Error. Closing ) encountered. %s popped off the stack. , stack.pop())
If the stack is not empty after processing every line, one or more opening parentheses were not closed in the file. This case should be handled as well. Print "stack not empty, not all parentheses closed."
if all parentheses are balanced, print "Parentheses are balanced."
Also, implement a main method that reads in a source file, adds each line to a list of strings, and runs containsMismatchedParenthese on the list (the main method must handle an IOException, you can use a Scanner wrapping a FileInputStream to read in the source to check, the path to the file to be checked must be read in from the args[0] element of the command line arguments array).
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