a guest Oct 15th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  2. import java.util.*;public class SyntaxChecker {private String expression; // expression to validate   private Stack<String> stack; // holds opening symbols ONLYprivate String open; // opening symbolsprivate String close; // closing symbols   // TODO: initialize the instance variables expression, stack, open, close      public SyntaxChecker(String open, String close, String exp)    {}// TODO complete the checkExpressions method that determines if the expression// has a closing symbol for every opening symbol   // @return true if the expression is valid, false otherwisepublic boolean checkExpression()   {            return false;}   // This method calls the checkExpression method and will determine if the    // expression is valid (every opening symbol, has a closing symbol)   // A string is return with a validation message    // @return a validation message   public String validate()   {      String result="";      if (checkExpression()==true)result += expression + " is correct\n";elseresult += expression + " is incorrect\n";return result;   }public String toString()   {return "Expression: " + expression + "\nStack: " + stack + "\nOpen: " +open + "Close: " + close;}}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand