Write a method named pigLatin
that accepts as a parameter a Scanner
representing an input file.
Your method should, preserving line breaks, print out the input file's text in a simplified version of Pig Latin, a silly English variant where the first letter of each word is moved to the end.
The rules for translating a word to Pig Latin are as follows:
-
If the word starts with a vowel (aeiou), simply append "yay".
For example, "elephant" becomes "elephantyay".
-
If the word starts with a consonant, move the consonant to the end, and append "ay".
For example, "welcome" becomes "elcomeway".
As an overall example, if the input file lincoln.txt contains the following text:
four score and
seven years ago our
fathers brought forth on this continent a new nation
We might call your method as follows:
Scanner input = new Scanner(new File("lincoln.txt"));
pigLatin(input);
The above call should produce the following output:
ourfay coresay andyay
evensay earsyay agoyay ouryay
athersfay roughtbay orthfay onyay histay ontinentcay ayay ewnay ationnay