what is wrong with this code?........from the beginners problem Transform The Expressions.

import java.io.IOException;
import java.util.EmptyStackException;
import java.util.Scanner;
import java.util.Stack;

class ReversePolishNotation {

public static void main(String[] args) throws IOException {
	Scanner KB=new Scanner(System.in);
	int t=KB.nextInt();
	while(t-->0)
	{
		String s=KB.next();
		Stack st=new Stack();
		char ch;
		for(int i=0;i<s.length();i++)
		{
			ch=s.charAt(i);
			if(ch>='a' && ch<='z')
			{
				System.out.print(ch);
			}
			 else if(ch==')')
			{
				 try{
			  System.out.print(st.pop());
				 }
				 catch(EmptyStackException e)
				 {
					 
				 }
			  
			}
			 else if(ch=='(')
			 {
			 }
			 else
			 {
				 st.push(ch);
			 }	
		}
		}
}

}

You did not add new line character after for loop, resulting all answers are coming in one line, so It’s giving wrong answer. Otherwise your logic is correct… Refer correct solution from here:

https://www.codechef.com/viewsolution/14608562

//