For my homework assignment, we are supposed to use stacks to make a calculator using infix and postfix in java. While I am reading in the equations from the file, there are lots of parentheses. I am supposed to make sure they match up and have an error message to display if they are empty, or if there are parenthesis that match up. I'm not sure how to go about checking for matching parenthesis. Any code, or help with the logic behind it would help. I have wasted a large amount of time trying to figure out a pretty small part of this homework.
The input file contains: (((A + B) - (C - D)) / (E - F)) (((A))) (A) ((A (B D) D)) () (( )) (((A + B))) ((A * B)) (A / B) A * B A / B + C A ^ (B - C) (((C ^ E))) D ( A - B * C) A- B / C ( A / B * C) ( A - C ^ C) ( A * C ^ C) ( D / C ^ C) A - C ^ C A - B * C +D / E A*B - C ^ C ^ D A B - C ^ C ^ D (( A - B * C) ^ D ^ E) ^ ( F / G * H + I ) (A - B) * (( C * D ) + E) ((( )(( ) )(((( )))) ((( )(( ) (((( )))) A * ( B / C) + D( A - B) A * ( B / C) + D ^ ( A - B) A * ( B / C) + D ^ A - B