+ 3
what's wrong in my code?
5 Respostas
+ 6
Indexes of string 'a' are in the range from 0 to a.length() - 1, but in the last iteration of for-loop you read char with index a.length() which is out of bounds.
Line #10 should be
for(int i=1;i<b;i++)
+ 4
At first, you should convert each word of the string. Use split(" ") method to split the input string into words.
To convert each word to piglatin you don't need to iterate that word. You just need to get substring starting from 2nd character, append the first character and append "ay".
Or in code:
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
String result = "";
for(String w: a.split(" ")){
if(!result.isEmpty()) result += " ";
result += w.substring(1) + w.charAt(0) + "ay";
}
System.out.print(result);
+ 2
andriy kan Didn't get my expected output. What's wrong in my 12th line?
+ 2
https://www.sololearn.com/coach/16?ref=app it's my task andriy kan