Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA: Write a program that converts words to the CS1 dialect of Pig Latin1. This

ID: 3779831 • Letter: J

Question

JAVA:

Write a program that converts words to the CS1 dialect of Pig Latin1. This program has several steps. To begin, you will first implement an isVowel method, which takes as arguments a character (the input to be tested) and a Boolean flag, which tells you whether or not ‘Y’ should be counted as a vowel – your method should return true if the input is a vowel, whether it is in upper- or lower-case.

Next, write the pigLatin method, which accepts a single String argument and returns the Pig Latin translation as a String. Here are the basic rules for our dialect:

1. If the first letter in the word is in (A, E, I, O, U), add “way” to the end

2. Otherwise, find the first letter (left-to-right) that is in (A, E, I, O, U, Y), move all characters before it to the end of the word, and append “ay”

a. If the first letter of the word was capitalized, you should make sure that the first letter of the translation is capitalized, and that the moved first letter is made lower-case (no other capitalization changes should be made)

Finally, write the main method, which should prompt the user for a word, translate it into Pig Latin, and repeat until the user enters “exitway” (“exit” in Pig Latin; any case should be acceptable). Consider the following example run of the program:

Enter a word to translate (exitway to finish): Extra

Extraway

Enter a word to translate (exitway to finish): Credit

Editcray

Enter a word to translate (exitway to finish): eXitwaY

To write this program you may find it useful to reference the Oracle documentation for the String class2, which has several useful methods. In particular, see the substring and toUpperCase/toLowerCase methods, in addition to the length, equals, and charAt methods we’ve covered in class.

This is the format:

   /**
   * Code word to exit
   */
   static final String EXIT_WORD = "exitway";
  


   /**
   * Indicates whether a character is a vowel
   *
   * @param c character in question
   * @param countY if true, the letter 'y'/'Y' counts as a vowel
   * @return true if the character is a vowel
   */


   public static boolean isvowel(char in)
//enter code here:

  


   /**
   * Returns the input word converted into pig latin
   *
   * @param s input word
   * @return pig latin version of input
*/


public static String pigLatin(String s) {

//enter code here:

}

   /**
   * Program execution point:
   * input words,
   * output each in pig latin
   *
   * @param args command-line arguments (ignored)
   */

   public static void main(String[] args) {
//enter code here:

Explanation / Answer

Please find the code below. I have explained every step through in-code comments. Good luck.