我正在用Java编写一个程序,我应该将英语句子翻译成类似于猪拉丁语的语言,只是有一些不同的规则。 到目前为止,我已经编写了代码,但它似乎只是一次翻译一个单词而不是整个句子。你能告诉我哪里出错了吗?继承我的代码:
import java.util.Scanner;
public class PartD {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter a phrase to convert: ");
String phrase = keyboard.nextLine();
String[] words = phrase.split(" ");
for(int i = 0; i < words.length; i++ ) {
char firstLetter = (words[i].charAt(0));
if (firstLetter == 'a' || firstLetter == 'e' || firstLetter == 'i' || firstLetter == 'o' || firstLetter == 'u'){
String vowel = words[i] +"-eh";
System.out.print(vowel);
}else{
String start = words[i].substring(0,1);
String end = words[i].substring(1,phrase.length());
System.out.print(end + "-" + start + "eh" );
}
}
System.out.println( );
}
}