我希望這能找到你。將單詞轉換成豬拉丁語
我對Java和本網站來說還是比較新的東西。雖然這可能看起來很長,但我只需要兩件事情的幫助,所以請幫助,而且就像我說的,我對所有這些都是新手,所以越徹底越好。我必須做一個項目,我們必須將常規英語單詞轉換成豬拉丁語。我錯過了我們的教練想要添加的一些東西。他是我現在的代碼。
import java.util.Scanner;
public class PigLatin
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
final String vowels = "aeiouAEIOU";
System.out.println("Enter your word.");
String word = sc.nextLine();
while (!word.equalsIgnoreCase("done"))
{
String beforVowel = "";
int cut = 0;
while (cut < word.length() && !vowels.contains("" + word.charAt(cut)))
{
beforVowel += word.charAt(cut);
cut++;
}
if (cut == 0)
{
cut = 1;
word += word.charAt(0) + "w";
}
System.out.println(word.substring(cut) + beforVowel + "ay");
System.out.println("Enter your word.");
word = sc.nextLine();
}
}
}
我不能的代碼似乎是實施「如果單詞沒有元音,打印‘無效’」,例如,如果我在bcdfgh鍵入這段代碼,它讀回bcdfgh唉。但它應該說無效
另一件事我不能添加代碼是這個「如果第一個元音是一個」你「,並且它之前的信是一個」Q「那麼」U「也會到這個單詞。」例如,如果我在此代碼中輸入問題,它會讀取uestionqay。但我想說它estionquay。
請和謝謝
我看到你拒絕了我的編輯。這是爲什麼?我只是想幫忙。 –
即時對不起,我認爲這些編輯是電腦生成的,其中一個編輯完全改變了我想說的話。如果我知道用戶編輯了它,我將永遠不會拒絕它。對不起 – user10101010