Question: Write a java program that designs a new gibberish language. Rules of the new language: 1. Words that begin with a consonant: All letters before
Write a java program that designs a new gibberish language. Rules of the new language:
1. Words that begin with a consonant: All letters before the initial vowel are placed at the end of the word followed by the word "and" which is added as a suffix at the end of the word.
For example: hello -> ellohand
2. Words that begin with multiple consonants: The whole consonant cluster is added to the end of the word followed by the suffix "and.
For example: child -> ildchand
3. Words that begin with vowels (a, e, i, o, u): convert as above but also prefix the word with the letter "v".
For example: it-> vitand
4. Words that have no vowels: Words that have no listed vowels (a, e, i, o, u) should be left alone. No need to be converted.
5. Data Validation: Ensure that the length of the string is at least one or you should display a validation error and cease execution
Using the following four methods:
getSentence(Scanner keyboard) - Called from the main() method and accepts as a parameter, a scanner object. This method should prompt the user for the word/phrase to convert and return the string input by the user.
convertToNewLanguage (Scanner wordScanner) - Called from the main method and accepts a secondary scanner object (Scanner wordScanner = new Scanner(phrase)) that is pointing to that String. This method gradually builds the new language converted string by going through the phrase word-by-word and making use of a helper method called convertWord(). Returns a string representing the fully converted language for the phrase.
convertWord(String word) - Called from within convertToNewLanguage() and accepts a single word as a string parameter. This method converts the single word and returns it to the convertToNewLanguage() method.
isVowel(char ch) - Called from convertWord(), this boolean helper method accepts a single character and returns a boolean true if the character is a vowel (a, e, i, o, u) and false otherwise.
Sample Run:
Enter the phrase to be converted: Java is cool
==> AVAJAND VISAND OOLCAND
Enter the phrase to be converted: <-- user hits enter key without inputing any data
==> Input phrase required. Cannot continue.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
