Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CountSpecifiedWord {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String text = "";
- text += input.nextLine().toLowerCase();
- String[] countWords = text.split("[^a-zA-Z0-9']+");
- int count = 0;
- String check = input.nextLine().toLowerCase();
- for (String string : countWords) {
- if (!string.equals(" ") && !string.equals("")) {
- if (string.equals(check)) {
- count++;
- }
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement