Question: Use java to complete the following- A common problem for compilers and text editors is to determine if the parentheses (or other brackets) in a
Use java to complete the following-
A common problem for compilers and text editors is to determine if the parentheses (or other brackets) in a string are balanced and properly nested. For example, the string ((())())() contains properly nested pairs of parentheses, but the string )()( does not, and the string ()) does not contain properly matching parentheses.
In this assignment the user is to enter an expression that contains parentheses. The program will then parse the expression checking to see if the parentheses are balanced or not. This is an essential step, there must be a prompt for input. You should use a stack to implement this function.
Once parsed the program should return the position in the expression of the offending parenthesis if it is determined the parentheses are not balanced in the expression. The program needs to check if there is an excessive amount of right or left parentheses. If the parentheses in the expression are balanced the program should print out that they are.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
