Write a program that checks if a given sequence consisting of just the two characters '(' and ')' is balanced. In class we discussed what it means to be balanced. For example, the sequence (())() is balanced, whereas the sequence (()))( and (()() are not balanced. Since we have only the characters '(' and ')', you should implement the simple counter based solution and not the stack based solution which we discussed in detail for the more general case when we have multiple characters.

You can assume that the input character sequence is given as an array of characters str as shown here . Feel free to add other methods and classes to this program (but you probbaly will not need to).