1// Aim: Program to perform String Character Count.
2import java.util.*;
3public class StringCharacterCount
4{
5 public static void main(String args[])
6 {
7 try (Scanner sc = new Scanner(System.in)) {
8 System.out.print("Enter a word : ");
9 String str = sc.nextLine();
10 int c=0;
11 System.out.print("Enter the letter to be counted : ");
12 String ch = sc.nextLine();
13 for(int i=0 ; i<str.length();i++){
14 if(str.charAt(i) == ch.charAt(0)){
15 c++;
16 }
17 }
18 System.out.println("The letter "+ch+" is repeated "+c+" times in the word "+str);
19 }
20 }
21}