Can someone help me with this? code: public class PigLatinator { /** * Takes a character array and arranges the characters into it's pig-latin form * * The rules for pig-latin are as follows: * 1. If...


Can someone help me with this?


code:


public class PigLatinator

{


/**
* Takes a character array and arranges the characters into it's pig-latin form
*
* The rules for pig-latin are as follows:
* 1. If a word starts with a consonant, search through the word beginning at index 0 for the first

* instance of a vowel. Split the array at this vowel, moving the consonants to the back of the array,

* following a '-'. The add 'ay' at the end of the word.
* 2. If a word starts with a vowel add the word "yay" at the end of the word following a '-'.
* 3. If a word contains no vowels, just add "ay" at the end of the word following a '-'.
* 4. If input is null, return null.
*

* Hint: Use your isVowel method to cut down on repetitive code
* NOTE: Do not use string methods to rearrange your arrays; you should use the indexes
*
* Example: char[] input = {'h', 'e', 'l', 'l', 'o'} gives
* char[] output = {'e', 'l', 'l', 'o', '-', 'h', 'a', 'y'}
* char[] input = {'f', 'l', 'a', 'r', 'e'} gives
* char[] output = {'a', 'r', 'e', '-', 'f', 'l', 'a', 'y'}
* char[] input = {'i', 't'} gives
* char[] output = {'i', 't', '-', 'y', 'a', 'y'}
* char[] input = {'s', 'h', 'h'} gives
* char[] output = {'s', 'h', 'h', '-', 'a', 'y'}
*

*
* @param input The char array to rearrange to pig-latin.
* @return A new char array containing the pig-latin of input. If input is null, return null.
*/
public static char[] pigLatin(char[] input)
{


return null;
}


/**
* This method is to transform words that begin with a consonant into pig-latin.
* If a word starts with a consonant, search through the word beginning at index 0 for the first

* instance of a vowel. Split the array at this vowel, moving the consonants to the back of the array,

* following a '-'. Then add 'ay' at the end of the word.
* If a word contains no vowels, just add "ay" at the end of the word following a '-'.
* NOTE: Do not use string methods to rearrange your arrays; you should use the indexes
*

* @param input - The char array to rearrange to pig-latin.
* @return A new char array containing the pig-latin of input.
*/
public static char[] startsConsonant(char[] input) {


return null;
}


/**
* This method is to transform words that begin with a vowel into pig-latin.
* If a word starts with a vowel add the word "yay" at the end of the word following a '-'.
* NOTE: Do not use string methods to rearrange your arrays; you should use the indexes
*

* @param input - The char array to rearrange to pig-latin.
* @return A new char array containing the pig-latin of input.
*/


public static char[] startsVowel(char[] input) {


return null;
}
/**
* Takes a letter, and checks if it is a vowel, then returns true is yes, false if no.
*

* Vowels are: a, e, i, o, u

* (Note: We are not considering y for this program.)
*

* @param letter, the letter being checked if it is a vowel
* @return A boolean, true if letter is vowel, otherwise false
*/
public static boolean isVowel(char letter)
{


return false;
}


/**
* This is test method for the pigLatin() method
*

* This method already contains 3 tests, but you should consider adding more to

* test different input.
*

*/
public static void testPigLatin()
{
char arr[] = {'f', 'l', 'a', 'r', 'e'};
char arr2[] = {'b', 'o', 'o', 'k'};
char arr3[] = {'i', 't'};






System.out.print("Expected: are-flay\nActual: ");
System.out.println(pigLatin(arr));
System.out.print("Expected: ook-bay\nActual: ");
System.out.println(pigLatin(arr2));
System.out.print("Expected: it-yay\nActual: ");
System.out.println(pigLatin(arr3));




}


/**
* This is the main method of your program. This is where we will call our test method.
*

* @param args
*/


public static void main(String[] args)
{
testPigLatin();
}
}


8.17 **zyLab: Pig-Latin<br>Write this program using an IDE. Comment and style the code according to the CS 200 Style Guide. Submit the source code files (.java)<br>below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct.<br>This program will translate a word into pig-latin. Pig-latin is a language game in which words in English are altered, usually by removing<br>letters from the beginning of a word and arranging them into a suffix.<br>The rules we will use for the pig-latin in this program are as follows:<br>1. If a word starts with a consonant, split the word at the first instance of a vowel, moving the beginning consonants to the end of the<br>word, following a''. Then add 'ay' at the end of the word. Vowels are: a, e, i, o, u (Notice: We are not considering y a vowel for this<br>program)<br>2. If a word starts with a vowel add the word

Extracted text: 8.17 **zyLab: Pig-Latin Write this program using an IDE. Comment and style the code according to the CS 200 Style Guide. Submit the source code files (.java) below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct. This program will translate a word into pig-latin. Pig-latin is a language game in which words in English are altered, usually by removing letters from the beginning of a word and arranging them into a suffix. The rules we will use for the pig-latin in this program are as follows: 1. If a word starts with a consonant, split the word at the first instance of a vowel, moving the beginning consonants to the end of the word, following a''. Then add 'ay' at the end of the word. Vowels are: a, e, i, o, u (Notice: We are not considering y a vowel for this program) 2. If a word starts with a vowel add the word "yay" at the end of the word following a '-'. Examples: • hello translates to ello-hay • flare translates to are-flay • it translates to it-yay A more detailed explanation of the requirements for each method will be in the method header comments - please follow these closely. Suggested order of completion: isVowel() then pigLatin(). Created by India Archer. Spring 2021: Revised by Taylor Mehmen. Reviewed by Dakota Sullivan. 10/27 jimw Dropped isVowel Method call test since acceptable implementations wouldn't pass. 10/28 apk Updated pigLatin unit test to improve consistency of test feedback for methods with undesirable side effects (i.e. modifying the input array). 295530.1815300.qx3zqy7
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here