(1+(2-3)/4+[(a-({b+c}*5)/2)+e] (a{b(c]}a)

CIS265 – Homework 4
(Problem 25.6)
Due: April 17th
(Matching grouping symbols) A Java program uses various pairs of grouping symbols, such
as:



Parentheses: ( and ).
Braces:
{ and }.
Brackets:
[ and ].
Note that the grouping symbols cannot overlap. For example, (a{b)} is illegal. Write a
program to check whether a Java source-code file has correct pairs of grouping symbols.
Requirements
1. You must implement and use a Stack<E> class to solve this problem. Your class needs
to implement the user-defined operations: push, pop, and peek.
2. Your Stack<E> class must be based on dynamic-linked lists as discussed in class
(see Chapter 26).
3. Do NOT use arrays, ArrayLists, JDK Stack to implement your Stack class.
Test the program with the following data set; put these lines in a disk text file. Read
each line, print each line, and tell whether or not each has a correct pairing of
grouping symbols.
[a({b,c}x{d,e})%x]
(1+(2-3)/4+[(a-({b+c}*5)/2)+e]
(a{b(c]}a)