Answer:
Step-by-step explanation:
PiLatinWithMultipleWords.java
import java.util.Scanner;
public class PiLatinWithMultipleWords {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter a string to be translated: ");
String s = scan.nextLine();
String words[] = s.split("\\s+");
for(String word: words){
System.out.print(pigLatin(word)+" ");
}
System.out.println();
}
public static String pigLatin (String s){
s = s.toLowerCase();
s = s.substring(1,s.length())+ s.charAt(0) + "ay";
return s;
}
}
Output
Enter a string to be translated: the fox jumps over the lazy dog
hetay oxfay umpsjay veroay hetay azylay ogday