Source_Code/myinterpreter/BackEnd.java
//This method checks whether the given user input is valid or not
This method checks whether the given user input is valid or not
This method checks whether the given user input is valid or not
public boolean inputValidation(String givenString) throws ICException,PException
			{
			Stack<Character> paranthesisHolder=new Stack<Character>();
			for(int i=0;i<givenString.length();i++)
				{
				if(givenString.charAt(i)=='*'||givenString.charAt(i)=='%'||givenString.charAt(i)==' '||givenString.charAt(i)=='-'||givenString.charAt(i)=='('||givenString.charAt(i)==')'||givenString.charAt(i)=='+'||givenString.charAt(i)=='='||givenString.charAt(i)=='/'|| (givenString.charAt(i) <=57 && givenString.charAt(i)>=48)||(givenString.charAt(i)<=90&&givenString.charAt(i)>=65)||(givenString.charAt(i)<=122&&givenString.charAt(i)>=97))
					{
					if(givenString.charAt(i)=='(')
						{
						paranthesisHolder.push((Character)givenString.charAt(i));
						}
					else if(givenString.charAt(i)==')')
						{
						if(paranthesisHolder.size()!=0)
							paranthesisHolder.pop();
						else
							throw new PException();
						}
					}
				else
					{
					throw new ICException();	
					}
				}	
			if(paranthesisHolder.size()!=0)
				throw new PException();
			return true;
			}
public boolean inputValidation ( String givenString ) throws ICException , PException { Stack < Character > paranthesisHolder = new Stack < Character > ( ) ; for ( int i = 0 ; i < givenString . length ( ) ; i ++ ) { if ( givenString . charAt ( i ) == '*' || givenString . charAt ( i ) == '%' || givenString . charAt ( i ) == ' ' || givenString . charAt ( i ) == '-' || givenString . charAt ( i ) == '(' || givenString . charAt ( i ) == ')' || givenString . charAt ( i ) == '+' || givenString . charAt ( i ) == '=' || givenString . charAt ( i ) == '/' || ( givenString . charAt ( i ) <= 57 && givenString . charAt ( i ) >= 48 ) || ( givenString . charAt ( i ) <= 90 && givenString . charAt ( i ) >= 65 ) || ( givenString . charAt ( i ) <= 122 && givenString . charAt ( i ) >= 97 ) ) { if ( givenString . charAt ( i ) == '(' ) { paranthesisHolder . push ( ( Character ) givenString . charAt ( i ) ) ; } else if ( givenString . charAt ( i ) == ')' ) { if ( paranthesisHolder . size ( ) != 0 ) paranthesisHolder . pop ( ) ; else throw new PException ( ) ; } } else { throw new ICException ( ) ; } } if ( paranthesisHolder . size ( ) != 0 ) throw new PException ( ) ; return true ; }
This method checks whether the given user input is valid or not
This method checks whether the given user input is valid or not