import java.util.Scanner;
public class pigLatin
{
public static void main(String[] args)
{
Scanner stdIn=new Scanner(System.in);
String word;
String newWord;
String repeatAgain = "y";
while (repeatAgain.equals("Y") || repeatAgain.equals("y"))
{
System.out.print("\f");
System.out.print("Enter a word: ");
word=stdIn.nextLine();
if (word.charAt(0)=='a' ||word.charAt(0)=='A' || word.charAt(0)=='e' || word.charAt(0)=='E' || word.charAt(0)=='i' || word.charAt(0)=='I' || word.charAt(0)=='o' || word.charAt(0)=='O' || word.charAt(0)=='u' || word.charAt(0)=='U')
{
newWord= word + "way";
}
else
{
newWord=word.substring(1) + word.charAt(0) + "ay";
}
System.out.println("That word translates to " + newWord + " in Pig Latin");
System.out.println("Do you want to play again? (y/n)");
repeatAgain = stdIn.nextLine();
}
}
}
Thank you!!!

New Topic/Question
Reply


MultiQuote




|