CALLING A METHOD

please someone help me how to the method in order to translate the entered sentence but i can't call the method...so can anyone help?


[code]
import java.util.StringTokenizer;
public class PIGLATIN
{

public static void main(String[] args) {
System.out.println("Enter Sentece: ");
PIGLATIN tokenizer = new PIGLATIN(); // create a new instance of Tokenizer
tokenizer.translate();// call the public translate method

}

public String translate (String sentence)
{
String result = "";
sentence = sentence.toLowerCase();
StringTokenizer tokenizer = new StringTokenizer (sentence);
while (tokenizer.hasMoreTokens())
{
result += translateWord (tokenizer.nextToken());
result += " ";
}
return result;
}

private String translateWord (String word)
{
String result = "";
if (beginsWithVowel(word))
result = word + "way";
else
if (beginsWithBlend(word))
result = word.substring(2) + word.substring(0,2) + "ay";
else
result = word.substring(1) + word.charAt(0) + "ay";
return result;
}
private boolean beginsWithVowel (String word)
{
String vowels = "aeiou";
char letter = word.charAt(0);
return (vowels.indexOf(letter) != -1);
}
private boolean beginsWithBlend (String word)
{
return ( word.startsWith ("qu") );
}

}[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories