Write a program to accept a string .Convert it to upper case and count the number of double letter sequence in that string
Answers
Answered by
6
Answer:
import java.util.Scanner;
class CountDouble
{
public static void main(String arg[])
{
Scanner input = new Scanner(System.in);
int i,c=0,l;
System.out.println("Enter a string:");
String str = input.nextLine();
String str1 = str.toUpperCase();
l = str.length();
char ch1,ch2;
for(i=0;i<l-1;i++)
{
ch1 = str1.charAt(i);
ch2 = str1.charAt(i+1);
if(ch1==ch2)
c++;
}
System.out.println("Total number of double numbers: " +c);
}
Explanation:
Hope it is useful!
Similar questions
Math,
6 months ago
India Languages,
6 months ago
Biology,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago
Math,
1 year ago