reAay ouyay aay hizway ithway igPay atinLay Translated Are y

reAay ouyay aay hizway ithway igPay atin?Lay? (Translated: “Are you a whiz with Pig Latin?”) Write a program that converts an English phrase into a pseudo-Pig Latin phrase (that is Pig Latin that doesn’t follow all the Pig Latin syntax rules). Use predefined methods of the Array and string classes to do the work. For simplicity in your conversion, place the first letter as the last character in the word and prefix the characters “ay” onto the end. For example, the word “example” would become “xampleeay,” and “method” would become “ethodmay.” Allow the user to input the English phrase. After converting it, display the new Pig Latin phrase.
reAay ouyay aay hizway ithway igPay atin?Lay? (Translated: “Are you a whiz with Pig Latin?”) Write a program that converts an English phrase into a pseudo-Pig Latin phrase (that is Pig Latin that doesn’t follow all the Pig Latin syntax rules). Use predefined methods of the Array and string classes to do the work. For simplicity in your conversion, place the first letter as the last character in the word and prefix the characters “ay” onto the end. For example, the word “example” would become “xampleeay,” and “method” would become “ethodmay.” Allow the user to input the English phrase. After converting it, display the new Pig Latin phrase.

Solution

solution

package com.prt.test;

  
  

package com.prt.test;

  
  

   import java.util.Arrays;
   import java.util.Scanner;

   public class StringEncryption {

       public static void main(String[] args)
       {
   try{
           String concatedString1=\"\";//testing();
           StringBuffer encryptedString=new StringBuffer();
Scanner scanner = new Scanner(System.in);
          
           System.out.println(\"enter the string \");
          
           String userInput = scanner.nextLine();// to read the string
          
           String[] words=userInput.split(\"\\\\s\");//to split the words if user enter the string with period
          
           for(String word:words)
           {
               int numberOfSpacesadd=1;
               String subs=word.substring(0, 1);//to split the first letter
               String s1=word.substring(1);//to split the after the first letter
               String concatedString=s1+subs;
               concatedString1=concatedString+\"ay\";//to add the adding phrase
               String addSpace = String.format(\"%\"+ numberOfSpacesadd +\"s\", \" \");//for adding the space after the word
                 

               encryptedString.append(concatedString1+addSpace);
              
              
           }
          
System.out.println(encryptedString.toString().trim()+\"?\");
   }catch(Exception e)
   {
       System.out.println(\" try another time\");
   }  
       }
   }
  

output

enter the string
Are You a Whiz with Pig Latin?
reAay ouYay aay hizWay ithway igPay atin?Lay?

 reAay ouyay aay hizway ithway igPay atin?Lay? (Translated: “Are you a whiz with Pig Latin?”) Write a program that converts an English phrase into a pseudo-Pig
 reAay ouyay aay hizway ithway igPay atin?Lay? (Translated: “Are you a whiz with Pig Latin?”) Write a program that converts an English phrase into a pseudo-Pig

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site