2016-02-14 121 views
0

嗨,大家好我想编程一个猪拉丁语翻译,我卡住试图提示用户输入他们输入的短语中的第一个元音。我觉得我没有做好。从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

你有什么问题? – Guy

+0

我觉得我最困惑的是从那里往哪里前进。当我得到元音时,我将如何使用它将我的文字翻译成拉丁文字? – Yellow

+0

不要问用户。找到他们自己并替换他们。想想你会如何在纸上做。 – anaxin

回答

0

7生成的Pig Latin维基百科中提到的方法。 链接:https://en.wikipedia.org/wiki/Pig_Latin。 所以你不需要问用户的元音,你是那个应该识别元音的人。选择六种方法之一,写一个原型,然后再回来,如果你卡住了。 Ps:我会推荐你​​用维基中提到的最后一种方式,因为它更容易实现。

相关问题