This is Discussion thread about Replace all π
Discussion About Replace all π
import java.util.*;
class GFG {
public String replacePi(String input)
{
String output = “”;
int size = input.length();
for (int i = 0; i < size; ++i) {
if (i + 1 < size && input.charAt(i) == 'p' && input.charAt(i + 1) == 'i') {
output += "3.14";
i++;
}
else {
output += input.charAt(i);
}
}
return output;
}
public static void main(String args[])
{
GFG g = new GFG();
Scanner s=new Scanner(System.in);
int n=s.nextInt();
for(int i=0;i<n;i++){
String input =s.nextLine();
System.out.println(g.replacePi(input));
}
}
}
why my this code is not being accepted