| |
L.A.13.3 - Piglatinator | page 12 of 12 |
"Astahay alay istavay, abybay." - The Piglatinator
Assignment:
Your assignment is to create an English to Pig Latin translator.
Your program should begin by explaining its function to the user. It should then do the following until the user responds to the final question negatively:
Ask the user to enter an English phrase.
Translate the phrase word-by-word into Pig Latin. (Here, words are delineated by any combination of spaces, commas, periods, question marks, exclamation marks, semicolons, colons, hyphens, double quotes, or parentheses. A description of the algorithm for translating an English word into a Pig Latin word is given in part 3 below.)
Tell the user the Pig Latin translation of the phrase they entered above.
Ask the user if they would like to translate another English phrase.
Here's how to translate the English word englishWord into the Pig Latin word pigLatinWord :
If there are no vowels in englishWord , then pigLatinWord is just englishWord + "ay". (There are ten vowels: 'a', 'e', 'i', 'o', and 'u', and their uppercase counterparts.)
Else, if englishWord begins with a vowel, then pigLatinWord is just englishWord + "yay".
Otherwise (if englishWord has a vowel in it and yet doesn't start with a vowel), then pigLatinWord is end + start + "ay" , where end and start are defined as follows:
- Let start be all of
englishWord up to (but not including) its first vowel.
- Let end be all of
englishWord from its first vowel on.
- But, if
englishWord is capitalized, then capitalize end and "uncapitalize" start .
Instructions:
Use these sample phrases as inputs for your run outputs:
Hasta la vista baby. - the Terminator
System.out.println("I love Java");
I have never let my schooling interfere with my education. - Mark Twain
Here are sample run outputs.
I can translate English sentences and phrases into Pig Latin.
Please type an English sentence or phrase and then press <Enter>.
> Hasta la vista baby. - the Terminator
In Pig Latin that would be:
> Astahay alay istavay abybay. - ethay Erminatortay
Would you like to translate another phrase? y
Please type an English sentence or phrase and then press <Enter>.
> System.out.println("I love Java");
In Pig Latin that would be:
> Emsystay.outyay.intlnpray("Iyay ovelay Avajay");
Would you like to translate another phrase? y
Please type an English sentence or phrase and then press <Enter>.
> I have never let my schooling interfere with my education. - Mark Twain
In Pig Latin that would be:
> Iyay avehay evernay etlay myay oolingschay interfereyay ithway myay educationyay. - Arkmay Aintway
Would you like to translate another phrase? N
Turn in your source code and run outputs.
|