从java中的单词短语中获取元音

时间:2016-02-14 07:10:44

标签: java

嗨,大家好我正在尝试编写一个猪拉丁语翻译器,而我却试图提示用户输入他们输入的短语中的第一个元音。我觉得我没有做好。

当用户输入"白色" 我希望接下来的两个提示要求单词中的第一个元音。然后把它翻译成猪拉丁语。

有关如何入门的任何建议?谢谢!

这是我的代码:

 import java.util.Scanner;
 public class main
 {
public static void main(String[] args)
{
    Scanner sc = new Scanner(System.in);

    System.out.println("Please enter a 2 word phrase: ");
    String input = sc.nextLine();

    System.out.println("Please enter the first vowel in the first word: ");
    String input1 = sc.nextLine();
    System.out.println("Please enter the first vowel in the second word: ");
    String input2 = sc.nextLine();

}

1 个答案:

答案 0 :(得分:0)

维基百科上提到了7种产生猪拉丁语的方法。 链接:https://en.wikipedia.org/wiki/Pig_Latin。 因此,您不需要向用户询问元音,您应该识别元音。选择六种方法中的一种,写一个原型然后如果你被卡住就回来。 Ps:我建议您使用wiki中提到的最后一种方式,因为它更容易实现。