Write a program to accept a string. Convert the string to uppercase. Count and output the number of Consecutive letter pairs that exist in the string.
Answers
Answered by
9
Answer:
import java.util.*;
public class Program6 {
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter a Sentence : ");
String s=sc.nextLine();
s=s.toLowerCase();
int l= s.length();
s=' '+s+' ';
int i;char c,d;int a,b,j=0;
for (i=0;i<l;i++)
{
c=s.charAt(i);
d=s.charAt(i+1);
a=c;
b=d;
if(d==' ')
j=i;
if((a+1)==b)
System.out.println(s.substring(0,j));
}
}
}
Similar questions