import java.util.Scanner;
public class CountOccurencesOfChar {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter String: ");
String str = sc.nextLine();
System.out.println("Enter Character to count occurences: ");
String ch = sc.next();
char c = ch.charAt(0);
int totalChar = 0;
char temp;
for(int i = 0;i < str.length();i++)
{
temp = str.charAt(i);
if(temp == c) {
totalChar++;
}
}
System.out.println(c+" appears "+totalChar+ " times in Given String.");
sc.close();
}
}