import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WordOccurence {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
System.out.println(" Enter the String ");
String first = reader.readLine();
System.out.println(" Enter the Word to be searched");
String second = reader.readLine();
int count = 0;
String[] array = first.split(" ");
for (int i = 0; i < array.length; i++) {
if (array[i].equals(second))
++count;
}
System.out.println(" No. Of Occurences " + count);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class WordOccurence {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
System.out.println(" Enter the String ");
String first = reader.readLine();
System.out.println(" Enter the Word to be searched");
String second = reader.readLine();
int count = 0;
String[] array = first.split(" ");
for (int i = 0; i < array.length; i++) {
if (array[i].equals(second))
++count;
}
System.out.println(" No. Of Occurences " + count);
}
}
No comments:
Post a Comment