I am trying to make a endless loop pig Latin translator until the user enters a "q" to quit the program. I am having issues finalizing the while statement. The error that I am getting is as followed.
PigLatin.java:27: error: cannot find symbol } while (word != "q"); ^ symbol: variable word location: class PigLatin
Here is my source code:
import java.util.Scanner;
public class PigLatin {
public static void main(String[] args) {
System.out.println("Welcome to the pig latin convertor.");
do {
Scanner in = new Scanner(System.in);
String word, pig;
char first;
System.out.print("enter word or press 'q' to quit: ");
word = in.next();
word = word.toLowerCase();
System.out.println(word);
first = word.charAt(0);
if (first == 'a' || first == 'e' || first == 'i' ||
first == 'o' || first == 'u') // vowel
pig = word + "way";
else
pig = word.substring(1) + word.charAt(0) + "ay";
System.out.println("pig-latin version: " + pig);
} while (word != "q");
}
}