Skip to content

Instantly share code, notes, and snippets.

@gogi2811
Created April 29, 2019 19:44
Show Gist options
  • Save gogi2811/31b0d8685da9b1fb2edb6c032cfbebfe to your computer and use it in GitHub Desktop.
Save gogi2811/31b0d8685da9b1fb2edb6c032cfbebfe to your computer and use it in GitHub Desktop.
import java.util.*;
public class Main {
public static void main(String[] args) {
System.out.println(translate("dyzsa"));
}
static String vowels = "aeiou";
static String const_str = "ay";
static String const_vowel_str = "way";
static String outputWord;
static String finalWord;
static String consoWords = "";
static String vowels_words = "";
static boolean flag = false;
public static String translate(String word) {
char[] words = word.toCharArray();
for (int i = 0; i < words.length; i++) {
if (vowels.contains(String.valueOf(words[i]))) {
flag = true;
finalWord = adday(word, consoWords);
break;
} else {
consoWords = consoWords + "" + String.valueOf(words[i]);
//outputWord.add();
}
}
if (!flag) {
finalWord = adday(word, consoWords);
}
return finalWord;
}
public static String adday(String actualString, String conso) {
if (!flag) {
return finalWord = actualString + "" + const_str;
}
if (conso != "") {
char[] act = actualString.toCharArray();
for (int j = conso.length(); j < act.length; j++) {
if (finalWord == null) {
finalWord = String.valueOf(act[j]);
} else {
finalWord = finalWord + "" + String.valueOf(act[j]);
}
}
finalWord = finalWord + "" + conso + "" + const_str;
} else {
finalWord = actualString + "" + const_vowel_str;
}
return finalWord;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment