while this program works fine elsewhere it is not running here
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 Piremoval.main(Main.java:5)
here is my code
import java.util.*;
class Piremoval {
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
for(int i=1;i<=n;i++)
{
String z=in.nextLine();
System.out.println(sol(z,0,""));
}
}
public static String sol(String q,int i,String result)
{
if(i>=q.length())
return result;
if(q.substring(i,i+2)=="pi")
{
result=q.substring(0,i)+"3.14"+q.substring(i+2);
return(sol(q,i+4,result));
}
else
return(sol(q,i+1,result));
}
}