Due Date: Monday, February 14, 2022.
Please complete Lab 3 before you start working on the homework. In this homework, you will continue the work on the project started in the lab and implement a balance checker for parentheses, braces, and square brackets in a string.
a. Static Attributes.
In the Interface class, add two static attributes of type String called openSym and closedSym and initialize them as "([{<" and ")]}>" respectively. These will be used to identify open and closed elements in the string. It's important that the closing symbols be placed at the same index as the matching open ones.
b. Balance Function.
Add a function in the interface called balanceCheck that receives a string as parameter and that checks if the open and closed symbols that are stored in the two attributes defined at point a) above are well balanced. The function should return an integer with the value
The function should not output anything, just return the result.
To check if the string is balanced, declare a stack at the beginning of the function. Then you need a loop that goes through the string and looks at every character one by one. For each of them,
At the end of the loop, if the stack is empty, then return 0. Otherwise return 1.
c. Main.
In the main, comment out the call to testStack from the lab. Then declare an input string and ask the user to input it. You will need a scanner for this, and you can use either the function next, or nextLine. Then call the function balanceCheck to check if the string is well balanced, and output an appropriate message based on what value the function returns. Make sure not to call the function more than once even when checking for multiple values - hint: use a local variable to store the result. After that, ask the user if they want to test another string, and repeat the process until the user quits. You can handle the last part however you choose.
d. Test.
Here are some strings that you can test:
Upload all four .java files to Canvas, Assignments, Homework 5.