FINDING MISSING ELEMENTS IN A STRING

import java.io.*;
import java.lang.*;
class Misord
{
public static void main(String args[])throws IOException
{
check chk= new check();
String str1=chk.input();
String str4=chk.ord(str1);
chk.mis(str4);
}
}
class check
{
public String input()throws IOException
{
String x = " ";
System.out.println("Enter the String");
DataInputStream in = new DataInputStream(System.in);
x= in.readLine();
return(x);
}
public String ord(String str1)
{
char ch=' ';
String str2=str1;
String str3=" ";
int l=str2.length();
int i,j;
for(i=65;i<=90;i++)
{
for(j=0;j<=l-1;j++)
{
ch = str2.charAt(j);
{
if(((int)ch==i)||((int)ch==i+32))//change here has been done
{
str3=str3+ch;
str3=str3.trim();
}
}
}
}
System.out.println(str3);
return(str3);
}
public void mis(String str4)
{
String str5=str4.trim();
String s1=" ";
int i=0,j=0,f=0,p=0;
int l=str5.length();
System.out.println(l);
for(i=65;i<90;i++)
{
p=0;
for(j=0;j<l;j++)
{
if((str5.charAt(j)==i)||(str5.charAt(j)==i+32))
{
System.out.print(str5.charAt(j));
f=1;
p=1;
if(j==l-1)
f=0;
}

}

if(f==1&&p==0)
System.out.print((char)i);

}
}
}

/*
public void mis(String str4)
{
String str5=str4.trim();
String s1=" ";
int i=0,j=0,k;
int l=str5.length();
System.out.println(l);
i = (int)str5.charAt(0);
j=(int)str5.charAt(l-1);
System.out.println(i);
System.out.println(j);
for(k=i;k<=j;k++)
{
char ch= (char)k;
s1=s1+ch;
s1=s1.trim();
}
System.out.println(s1);
}
}
*/
Post a Comment