HW: Parentheses due Mon 01 May 10:00

\begin{purpose}
In this assignment you will:
\begin{itemize}
\item Apply a hand-coded stack to solve a common problem.
\end{itemize}
\end{purpose}

Description

In programming we sometime have expressions with quite a few parentheses in them. At times it can be challenging to know if you have them matched up properly. If your expression allows the use of multiple grouping symbols (e.g., (),[],{},<>) rather than just parentheses the problem gets a bit more complicated because you need to make sure that opening and closing pairs have the same type. Consider the following expression:
(x+y)/{[<(a+b)-(b-c)>+3] / (a - b)}

This expression would be considered valid because every open symbol has a corresponding close symbol. There are several ways the various grouping symbols could be incorrect:

Your program should use the generic MyStack class you wrote on lab day to solve the problem. The basic idea is that when you encounter an opening symbol you push it on the stack. When you encounter a closing symbol you pop an open symbol from the stack and make sure it is of the same type.

Beyond the requirement to use your own stack you can design the program how you want to. Here is sample output of my program for four sample strings:

Checking '(x+y)/{[<(a+b)-(b-c)>+3] / (a - b)}': Thumbs Up!
Checking '(x+y)/{[(a+b)-(b-c)} / (a - b)}': [ matched with }
Checking '(x+y)/{[(a+b)-(b-c)] / (a - b)})': Unmatched )
Checking '(((x+y)/{[(a+b)-(b-c)] / (a - b)})': Unmatched (

Your final program should demonstrate results for the following strings:

<{<[n/k]/e>/a}*z>+[m*l]/{k/w}^([([j+a]/a)/d]^h)/<o-e>^{r/a}*[t/u]+(v+g)-[(g^y)^s]/{}
<{<[n/k]/e>/a}*z>+[m*l]/{k/w}^([{[j+a]/a)/d]^h)/<o-e>^{r/a}*[t/u]+(v+g)-[(g^y)^s]/{}
[{{q^x}[n+n]/d}/o]+{<{<[s^z]{q^d}{e*c}-w>/f}(s/a)<h*f>+s><v/w><<(<q^o><>)>>}
[{{q^x}[n+n]/d}/o]+<{<{<[s^z]{q^d}{e*c}-w>/f}(s/a)<h*f>+s><v/w><<(<q^o><>)>>}
[{{q^x}[n+n]/d}/o]}+<{<{<[s^z]{q^d}{e*c}-w>/f}(s/a)<h*f>+s><v/w><<(<q^o><>)>>}

That is to say, when I run your program it should display the results of all five strings in the following format: The word ``Checking'' followed by a space and a single-quote, followed by the string being checked followed by a single-quote followed by a colon followed by a space followed by the result. The result should be:

Review the sample output from my program if you need clarification of the output requirements.

Grading

The assignment will be graded according to the following criteria:
Correctness 16 pts
Documentation 2 pts
Conventions 2 pts
Version Control 2 pts
Total 22 pts

Your program should be completely working and should follow all of the programming conventions named in class and explained in http://josephus.hsutx.edu/classes/all/javaconventions/ (including the use of comments that conform to the JavaDoc guidelines).

The instructor will grade your work based on what you have pushed to the hosted homework repository you have shared. For all assignments the program is due before the beginning of class on the due date. Repositories that show a commit time after that time will be graded as late.

Quick Links