Question: Create a program that takes a word and transforms it to Pig Latin using String methods. You may need the word's length, a substring that

Create a program that takes a word and transforms it to Pig Latin using String methods. You may need the word's length, a substring that does not include the first letter, and a substring that is just the first letter (you can get the ith letter of a string using substring(i,i+1) so for example the letter at index 3 would be substring(3,4)).

Use the substring method to transform a word into Pig Latin where the first letter is put at the end and "ay" is added. The word pig is igpay in Pig Latin.

public class PigLatin

{

   public static void main(String[] args)

   {


 

       String word =


 

       // Use word.substring to construct word in pig latin

       String pigLatin =


 

       System.out.println(word + " in Pig Latin is " + pigLatin);

   }

}


Step by Step Solution

3.42 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class PigLatin public static void mainString args String word pig String pigLatinWord co... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!