Answer:
The code is below
Step-by-step explanation:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
public class Main {
/**
*
* Iterate through each line of input.
*
*/
public static void main(String[] args) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
BufferedReader in = new BufferedReader(reader);
String line;
while ((line = in.readLine()) != null) {
String[] splittedInput = line.split(";");
String pattern = splittedInput[0];
String blobs = splittedInput[1];
Main.doSomething(pattern, blobs);
}
}
public static void doSomething(String pattern, String blobs) {
// Write your code here. Feel free to create more methods and/or classes
int sum = 0;
String arrblobs[] = blobs.split("\\|");
for (int i = 0; i < arrblobs.length; ++i) {
int answer = 0, index = 0;
for (;;) {
int position = arrblobs[i].indexOf(pattern, index);
if (position < 0)
break;
answer++;
index = position + 1;
}
System.out.print(answer + "|");
sum = sum + answer;
}
System.out.println(sum);
}
}