@@ -0,0 +1,1504 @@
+// Parantheses checker.%0A%0Aimport java.util.*;%0Aimport java.io.*;%0A%0Apublic class Parantheses%7B%0A%09%0A%09public static void main(String args%5B%5D) throws IOException%7B%0A%09%09Scanner scanInput = new Scanner(System.in);%0A%09%09String str;%0A%09%09Stack paranStack = new Stack();%0A%09%09char ch;%0A%09%09Character chPopped;%0A%09%09boolean isCorrect = true;%0A%09%09%0A%09%09System.out.println(%22Enter a string of parantheses expression : %22);%0A%09%09str = scanInput.nextLine();%0A%09%09int i, sLen = str.length();%0A%09%09for(i = 0; i %3C sLen; i++)%7B%0A%09%09%09ch = str.charAt(i);%0A%09%09%09if(ch == '(' %7C%7C ch == '%5B' %7C%7C ch == '%7B' )%7B%0A%09%09%09%09paranStack.push(ch);%0A%09%09%09%7D%0A%09%09%09else if(ch == ')')%7B%0A%09%09%09%09chPopped = (Character)paranStack.peek();%0A%09%09%09%09if((char)chPopped == '(' )%7B%0A%09%09%09%09%09paranStack.pop();%0A%09%09%09%09%7D%0A%09%09%09%09else%7B%0A%09%09%09%09%09isCorrect = false;%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09else if( ch == '%5D' )%7B%0A%09%09%09%09chPopped = (Character)paranStack.peek();%0A%09%09%09%09if((char)chPopped == '%5B')%7B%0A%09%09%09%09%09paranStack.pop();%0A%09%09%09%09%7D%0A%09%09%09%09else%7B%0A%09%09%09%09%09isCorrect = false;%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09else if( ch == '%7D' )%7B%0A%09%09%09%09chPopped = (Character)paranStack.peek();%0A%09%09%09%09if((char)chPopped == '%7B')%7B%0A%09%09%09%09%09paranStack.pop();%0A%09%09%09%09%7D%0A%09%09%09%09else%7B%0A%09%09%09%09%09isCorrect = false;%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09//If char peeked is not compatible with current bracket type. break and set isCorrect flag to false.%0A%09%09%09if (!isCorrect)%7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%7D%0A%09%0A%09//If the parantheses sequence is correct, the stack will be empty and boolean flag will also be true.%0A%09%09if( paranStack.empty() && isCorrect)%7B%0A%09%09%09System.out.println(%22True.%22);%0A%09%09%7D%0A%09%09else%7B%0A%09%09%09System.out.println(%22False.%22);%0A%09%09%7D%0A%09%09%0A%09%0A%09%7D%0A%7D%0A

Add Parentheses.java