Write a program that translates an English word into a Pig Latin word. Input ONE, and ONLY one, word from the user, and then output its translation to Pig Latin.
The rules for converting a word to Pig Latin follow.
If the word begins with a vowel (an element of "aeiouAEIOU") simply append "-way". For example, "example" becomes "example-way" and "All" becomes "All-way".
If the word begins with "th" (or "Th", "tH", or "TH"), remove the prefix and append "-thay" (or "-Thay", "-tHay", or "-THay") to the word. For example, "this" becomes "is-thay" and "The" becomes "e-Thay".
Use at least the REQUIRED METHODS listed below, with the exact same SPELLING for method names and parameters.
Input ONE English word as a string. If multiple words are entered ignore any beyond the first.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
Please enter a word ==> <user input>
Output an introductory message, a prompt for the English word, and a translation for the inputted word.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING. The output below assumes the user entered "Hunger".
This program will convert an English word into Pig Latin. Please enter a word ==> Hunger "Hunger" in Pig Latin is "unger-Hay"
// Prompt and read a word to translate String readWord (Scanner console) // Convert a word to Pig Latin and return it String convertWord (String englishWord) // Return true if "c" is a vowel, false otherwise. // Handle both lowercase and uppercase letters. boolean isVowel (char c) // Print result of translation void printResult (String englishWord, String pigLatinWord)
BEFORE you start coding, think about which methods each method will call. Which methods should "main" call? Create a diagram which shows the calling relationships.
There are many useful String methods listed HERE. You may find "startsWith" and "charAt" helpful.