JAVA PROGRAM FOR CONVERSION OF A NORMAL WORD TO UNIQUE WORD

JAVA PROGRAM 2 - CONVERSION OF A NORMAL WORD TO UNIQUE WORD



To begin with a unique word is a word which has no repetation like in Cat , Zelda ,Cube, Me,etc.
This program converts a normal word to a unique word.

Q :- 
INPUT : Application
OUTPUT :- Aplicton 

SOLUTION:-

import java.io.*;

class lambda

{

  static int check(String s,char p)

  {
int k=0;
   
      for(int i=0;i<s.length();i++)

     {

          p=Character.isLowerCase(s.charAt(i))?Character.toLowerCase(p):Character.toUpperCase(p);

         if(s.charAt(i)==p)

         k++;

         else

         continue;

   }

        return k;

    }

   public static void main(String args[])throws IOException

    {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String s,l="";

        s="";

        System.out.println("ENTER A STRING ");

        l=br.readLine();

       for(int i=0;i<l.length();i++)

        {

            int r= 0;

            r=check(s,l.charAt(i));

            if(r==0)

            s=s+l.charAt(i);
        }

       System.out.println("REQUIRED STRING :: "+s);


}


}


Comments

Popular Posts