Welcome to Dream.In.Code
Become a Java Expert!

Join 149,587 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,786 people online right now. Registration is fast and FREE... Join Now!




Pig Latin Translator

 
Reply to this topicStart new topic

Pig Latin Translator

mezig101
4 Oct, 2007 - 03:15 PM
Post #1

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
OMG! I have no clue what Im doing..I've been working on this for like 23456789098765 hours..and it's no help..I don't understand it sad.gif

I need to write a program that translates english words to pig latin..

Here's how to translate the English word into the Pig Latin word.
If there are no vowels in the English word, then the Pig Latin word is just the English word + "ay." (There are 10 vowels: 'a,' 'e,' 'i,' 'o,' and 'u,' and their upper-case counterparts.)
Else, if the English word begins with a vowel, then the Pig Latin word is just the English word + "yay."
Otherwise (if the English word has a vowel in it and yet doesn't start with a vowel), then the Pig Latin word is end + start + "ay," where end and start are defined as follows.
Let start be all of the English word up to (but not including) its first vowel.
Let end be all of the English word from its first vowel on.
But, if the English word is capitalized, then capitalize end and "uncapitalize" start.


well i still ONLY have this
CODE

import java.util.Scanner;
public class Piglatinator
{
    public static void main(String [] args)
    {
        System.out.println("Welcome to the Piglatinator Translator!");
        String str, another = "y";
        char vowel[]={'a','e','u','o','i'};
        
        Scanner scan = new Scanner(System.in);
        
        while(another.equalsIgnoreCase("y"))
        {
            System.out.println("Enter an English phrase: ");
            str = scan.nextLine();
                
            int a=0;            
            System.out.println();
            
            for(int i=0;i<str.length();i++)
            {
               a=i+1;
               if(str.charAt(i)==' ')
               {
                 for(int j=0;i<vowel.length;j++){
                 if(str.charAt(a)==vowel[j])
                 str.charAt(a);

                                        }                                  
                                    }
}
            
            System.out.println("Right another message(y/q)? ");
            another = scan.nextLine();
            
    }

}
}

User is offlineProfile CardPM
+Quote Post

mattman059
RE: Pig Latin Translator
4 Oct, 2007 - 03:25 PM
Post #2

D.I.C Regular
Group Icon

Joined: 23 Oct, 2006
Posts: 361


Dream Kudos: 175
My Contributions
I used to have this in C++ ill keep looking (dont know where it is) and ill let you know if i can help..
User is offlineProfile CardPM
+Quote Post

mezig101
RE: Pig Latin Translator
5 Oct, 2007 - 04:04 AM
Post #3

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
ughhh plz helpppppppppp sad.gif
User is offlineProfile CardPM
+Quote Post

mezig101
RE: Pig Latin Translator
5 Oct, 2007 - 01:38 PM
Post #4

D.I.C Head
**

Joined: 1 Aug, 2007
Posts: 54


My Contributions
arrrrrghh bump sleep.gif
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Pig Latin Translator
5 Oct, 2007 - 03:03 PM
Post #5

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
Well from your code I think you haven't think the algorithm haven't you? I mean you are onto something but not all the way.
Anyways, I would do this:

Write a function say isVowel() that would be say of type boolean, guess what that function is for, then use that function in the for loop like this

if the char at i-th position isVowel then just add "way" to the word. I would also use the class StringTokenizer, to get the words.

else then make that word a char array, and do the pig-latin thing, then make the char array into string and add the "ay" "yay" "whateverey" blink.gif so make sure you have a string at the end and just print it. Hope this is helpful.

Another thing this is a forum not a live chat, that means you'll get answer sooner or later, so be patient.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:04PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month