Question
Make an ArrayList of expressions with grouping symbols and output whether the grouping symbols match. Test for ( ), [ ], { }, and <
Make an ArrayList of expressions with grouping symbols and output whether the grouping symbols match. Test for ( ), [ ], { }, and < >. Type in the test data as shown in the sample run below. Use only the stack methods in java.util.Stack
that is our assignment
import java.util.*; public class ParenMatch { public static final String LEFT = "([{<"; public static final String RIGHT = ")]}>"; public static void main(String[] args) { System.out.println("Parentheses Match"); ArrayListparenExp = new ArrayList (); /* enter test cases here */ for( String s : parenExp ) { boolean good = checkParen(s); if(good) System.out.println(s + "\t good!"); else System.out.println(s + "\t BAD"); } } //returns the index of the left parentheses or -1 if is not public static int isLeftParen(String p) { return LEFT.indexOf(p); } //returns the index of the right parentheses or -1 if is not public static int isRightParen(String p) { return RIGHT.indexOf(p); } public static boolean checkParen(String exp) { } }
and this is the shell code we were given, I don't really understand the whol left paren right paren thing. Also paren here stands for parentheses.
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