Skip to main content

Printing Consecutive alphabets in a String

import java.io.*;
import java.lang.*;

class s

{
public void asc(String t)
{
 t=t.toUpperCase();


int p,f=0,q,d;

for(int i=65;i<=90;i++)
{
f=0;

for(int j=0;j<t.length()-1;j++)
{
p=(int)t.charAt(j);
q=(int)t.charAt(j+1);

d=q;
if(d==65)
d=91;

if((p==i)&&(d==i+1))
{

f+=1;

System.out.println((char)p+","+(char)q);

}

}
}

}

}


class Cons
{
public static void main(String args[])throws Exception
{
s ob=new s();
DataInputStream d = new DataInputStream(System.in);
String t;
System.out.println("Enter a String");
t= d.readLine();
ob.asc(t);

}
}

Comments

Popular posts from this blog

unix commands