Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. Since the Java Collections classes always store objects, not primitives, you could process either a stack of Strings or of Characters. The shell below uses Strings.

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"); ArrayList parenExp = 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

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: 3

blur-text-image

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Does our physical environment differ from that of the study unit?

Answered: 1 week ago

Question

what is lambda calculus?

Answered: 1 week ago