Question: Using the pseudo code algorithm below, write a method that takes a String parameter and determines whether the enclosing punctuations are correctly nested. It will

 Using the pseudo code algorithm below, write a method that takes

Using the pseudo code algorithm below, write a method that takes a String parameter and determines whether the enclosing punctuations are correctly nested. It will return true if they are, and false otherwise. You must account for parentheses, square brackets, and curly braces. Create an empty stack for characters For each character in the string if the character is ' (' or ' [' ' {' push it onto the stack else if the character is ') ' or '] ' or '} ' if the stack is empty return false else pop a character from the stack if the popped character is not the left version of the character being considered return false end if end if end for If the stack is not empty return false else return true end if Also, write a main method that prompts the user for a string and then calls and prints the return value of the above method. Using the pseudo code algorithm below, write a method that takes a String parameter and determines whether the enclosing punctuations are correctly nested. It will return true if they are, and false otherwise. You must account for parentheses, square brackets, and curly braces. Create an empty stack for characters For each character in the string if the character is ' (' or ' [' ' {' push it onto the stack else if the character is ') ' or '] ' or '} ' if the stack is empty return false else pop a character from the stack if the popped character is not the left version of the character being considered return false end if end if end for If the stack is not empty return false else return true end if Also, write a main method that prompts the user for a string and then calls and prints the return value of the above method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!