Computer Science, asked by daddysumi8664, 1 year ago

how to solve a program piglatin number

Answers

Answered by Anonymous
0
latin

I'm just wanting some input on to how others would approach this problem. I am learning and wish to gain insight on others techniques. Be as critical as you need. I want to learn. I feel this code is sloppy and the logic is confusing.

/* Pig Latin Write a program that reads a sentence as input and converts each word to “Pig Latin.” In one version, to convert a word to Pig-Latin you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHT Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY */

Answered by sou7474
0

class propereasypiglatin

{

   static void accept(String S)

   {

       String S1=S.trim();

       String s=S1.toUpperCase();

       char t=s.charAt(0);

       if(t=='A'||t=='E'||t=='I'||t=='O'||t=='U')

       {

        String s1=s.substring(1);

        String s2=s.substring(0,1);

        String s3="WAY";

        String f1=s1+s2+s3;

        System.out.println(f1);

       }

       else

       {

        String s4=s.substring(1);

        String s5=s.substring(0,1);

        String s6="AY";

        String f2=s4+s5+s6;

        System.out.println(f2);

       }

   }

}

Similar questions