我正致力于将英语转换为Pig-latin。如果第一个字母是一个则java应该打印整个单词,我试着说一句话。 当我输入苹果时,它会打印苹果,但如果我放入冷却,它也会打印出来。
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Assignment_4_Piglatin{
public static void main(String[] args){
Scanner userWord = new Scanner(System.in);
System.out.println("K. Caleb Swallow");
System.out.println("Welcome to the Pig Latin Translator!");
boolean run = true;
while(run){
System.out.println("Please enter a word(or press Q to quit):");
String firstLetter = "something";
String word = userWord.next();
System.out.println(word);
firstLetter = Character.toString(word.charAt(0));
String color = word;
if( firstLetter == "a"){
System.out.println(color);
}