the rule are: when the word starts in vowel letter it adds "way" if it starts in consonant it finds the first vowel letter and the letters before the vowel will be transfered in the end part of the word and add "ay"
the problem is when the word starts with consonant it translates but then the letter/s before the vowels isn't transferred in the end
ex:
inputted word: kulafo
output: ulafo+ay
here is the code:
import java.util.StringTokenizer;
import java.io.*;
public class kulafokiller {
private static char[] vowels ={'a', 'e', 'i', 'o', 'u'};
private static StringTokenizer tokenizer;
private static String word;
public static void getString()
{
BufferedReader kulafo = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter text to be translated");
try { String text = kulafo.readLine();
tokenizer = new StringTokenizer(text);
} catch (IOException e) {
System.out.println(e); }
while(tokenizer.hasMoreTokens())
{
word = tokenizer.nextToken();
System.out.println(shifter(word));
}
}
public static String shifter(String text)
{
// text = tokenizer.nextToken();
int length = text.length();
for(int x = 0; x < vowels.length; x++)
{
if(text.charAt(0) == vowels[x])
{
System.out.println("");
text+="way";
return text;
}
}
//System.out.println("flag1");
text += text.charAt(0);
//System.out.println("0 pos is" + text.charAt(0));
text = text.substring(0,length);
text+="ay";
return text;
}
public static void main(String[] args)
{
getString();
}
}

New Topic/Question
Reply



MultiQuote



|