import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
private static int total;
private static int numberOfWordsWithChar;
private static String words[];
private static char getChar() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
return s.charAt(0);
}
private static String getParagraph() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = "";
String s1 = br.readLine();
while (!s1.equals("")) {
s += s1 + " ";
s1 = br.readLine();
}
return s;
}
private static void process() throws IOException {
words = getParagraph().split(" ");
total = words.length;
numberOfWordsWithChar = countWords(getChar());
}
private static int countWords(char ch) {
int res = 0;
for (String str : words) {
if (str.startsWith(ch + "")) {
res++;
}
}
return res;
}
public static void main(String[] args) throws IOException {
process();
System.out.println("Total number of words: " + total);
System.out.println("Total number of words that starts with special character: " + numberOfWordsWithChar);
}
}
Comments
Leave a comment