New_TO_ JAVA @facing_some_errors


#1

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. /
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{int j,k;
Scanner scan =new Scanner(System.in);
int t=scan.nextInt();
while(t > 0){
j=0;
k=0;
String s=scan.nextLine();
for(int i = 0;i < s.length();i++)
{if( s.charAt(i) == ‘<’)
j++;
else if( j>0 && s.charAt(i) == ‘>’){
j–;
k++;
}
}
k=k
2;
System.out.println(k);
s = “0”;
t–;
}
}
}

Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Codechef.main(Main.java:13)