-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay35_prob1.java
More file actions
46 lines (34 loc) · 1.14 KB
/
Day35_prob1.java
File metadata and controls
46 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Ravi and Shanker are playing a game. Ravi is going to speak one sentence and ask that how many time in the sentence he used a word. Help Shanker to find occurance of word. Do not consider case (Upper or lower case) of the word.
Input Format
First line will contain one sentence.
Second line will contain one word which Shanker need to count.
Constraints
NA
Output Format
An integer value represents occurance of the word.
Sample Input 0
Keshav is playing a game and he is using a ball and a bat for it.
a
Sample Output 0
3
*/
// kirtan jain
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int count=0;
String[] a = sc.nextLine().replaceAll(","," ").replace(".","").toLowerCase().split(" ");
String b = sc.nextLine();
b=b.toLowerCase();
for(int i=0;i<a.length;i++){
if(a[i].equals(b)){
count++;
}
}
System.out.println(count);
}
}