I'm new to programming (this is my 3rd program ever)
We have an assignment to create a Pig Latin translator, but when i run it it repeats the answer over and over again. Not sure what I am doing wrong.
/****************** *Pig Latin Program Eddy Caraballo ******************/ import java.util.Scanner; public class PigLatin { public static void main(String[] args) { System.out.println("give me a word to translate or press 'q' to quit"); //displaying question// Scanner scan = new Scanner(System.in); String wordToTranslate = scan.nextLine(); //taking user input and creates new variable// char v = Character.toLowerCase(wordToTranslate.charAt(0)); //looking for the first letter of the word that is being input// while(!wordToTranslate.equalsIgnoreCase("q")) //should loop until "q" is entered// { if (v == 'a' || v == 'e' || v == 'i' || v == 'o' || v == 'u') //if first letter of inputted word is any of these letters(vowels)// { String pigLatinTranslation = wordToTranslate + "way"; //then create new word with way at the end// System.out.println(pigLatinTranslation); //displays new word// } else //otherwise// { String firstLetter = wordToTranslate.substring(0,1); //creates a new variable named firstLetter that comes from a section(substring) of "wordToTranslate" starting at character 0 and ending at character 1// String endOfWord = wordToTranslate.substring(1,wordToTranslate.length()); //creates a new variable named endOfWord that comes from a section(substring) of "wordToTranslate" starting at character 1 and ending at the length of the word// System.out.println (endOfWord + firstLetter + "ay"); } } } }
Thanks for any advice