4 Replies - 4463 Views - Last Post: 05 October 2007 - 04:03 PM Rate Topic: -----

#1 mezig101  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 01-August 07

Pig Latin Translator

Post icon  Posted 04 October 2007 - 04:15 PM

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 :(

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
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();
			
	}

}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Pig Latin Translator

#2 mattman059  Icon User is offline

  • Epic Awesomeness
  • member icon

Reputation: 15
  • View blog
  • Posts: 538
  • Joined: 23-October 06

Re: Pig Latin Translator

Posted 04 October 2007 - 04:25 PM

I used to have this in C++ ill keep looking (dont know where it is) and ill let you know if i can help..
Was This Post Helpful? 0
  • +
  • -

#3 mezig101  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 01-August 07

Re: Pig Latin Translator

Posted 05 October 2007 - 05:04 AM

ughhh plz helpppppppppp :(
Was This Post Helpful? 0
  • +
  • -

#4 mezig101  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 01-August 07

Re: Pig Latin Translator

Posted 05 October 2007 - 02:38 PM

arrrrrghh bump -_-
Was This Post Helpful? 0
  • +
  • -

#5 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: Pig Latin Translator

Posted 05 October 2007 - 04:03 PM

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: 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1