I am a high school student in a beginners programming class and I have to create a pig latin program that takes the first consonants and puts them to the end of the word and ads "ay". I really don't know what I'm doing and my code is printing out no words and I've tried to fix it and I don't know what the issue is because no error codes are showing up. I can't use arrays and can only use for loops, if/else, and while.
import java.util.Scanner; public class PigLatin { public static void main(String args[]) { Scanner input = new Scanner(System.in); System.out.println("Enter a phrase: "); String phrase = input.nextLine(); System.out.println("Here is your phrase in pig latin: " + sepword(phrase)); } public static String sepword(String phrase) { phrase = phrase + " "; String sentence = ""; for (int i = 0; i < phrase.length(); i++) { String word = ""; if (phrase.charAt(i) == ' ') { word = phrase.substring(0, i); if (word.charAt(0) == 'a' || word.charAt(0) == 'i' || word.charAt(0) == 'o' || word.charAt(0) == 'u' || word.charAt(0) == 'e') { sentence+=vowel(word); } else { sentence+=consonant(word); } } phrase = phrase.substring(i+1); } return sentence; } public static String vowel(String word) { return word+"-ay "; } public static String consonant(String word) { for (int i = 0; i < word.length(); i++) { String firstletters = ""; while (word.charAt(i) != 'a' || word.charAt(i) != 'i' || word.charAt(i) != 'o' || word.charAt(i) != 'u' || word.charAt(i) != 'e') { firstletters+=word.charAt(i); } word = word.substring(i)+"-"+firstletters+"ay "; } return word; } }