Skip to main content

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);
}
}
*/

Comments

Popular posts from this blog

PROGRAM TO PRINT COLOURS OF RAINBOW ACCORDING TO THE NO. INPUTTED BY THE USER

#include,stdio.h> #include<conio.h> void main() { int ch; printf("INPUT A NUMBER\n"); scanf("%d",&ch); switch(ch) { case 6: printf("Red"); break; case 5 : printf(" Orange"); break; case 4 : printf(" Yellow"); break; case 3 : printf(" Green"); break; case 2 : printf(" Blue"); break; case 1 : printf(" Indigo"); break; case 0 : printf(" Violet"); break; default : ("wrong input "); } } SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLE TEMPERATURE CONVERSION COMMISSION OF A SALESMAN PRINT NUMBERS IN DESCENDING ORDER BIGGEST NUMBER AMONG THREE NUMBERS CALCULATE DIVISION A YEAR IS LEAP OR NOT A NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5 PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTERED DATA STRUCTURES ENTER DETAILS OF A STUDENT ENTER DETAILS OF A ST...

unix commands

 

Baby doge paws

Baby doge paws link 🎉 Join the BabyDoge PAWS Clicker adventure! Solve challenges, join daily events, and invite friends. Stay tuned for the token airdrop! 🐾 🌟 Earn 10k PAWS as a welcome bonus 🌟 Get 25k PAWS with Telegram Premium https://t.me/BabyDogePAWS_Bot?start=r_6394860582