Java 17
Java 17
Date: 2022-06-15
ID: 20095A0363
Page No:
Aim:
Write a Java program to make frequency count of words in a given text.
Source Code:
WordCount.java
import java.io.*;
class WordCount {
String s = br.readLine();
int ind,count = 0;
for(int i = 0;i<str.length;i++)
if(str[i].equals(sub))
count++;
Test Case - 1
User Output
Enter some text: The first second was alright, but the second second was tough
Enter the word whose frequency is to be found: second
The frequency of word 'second' is: 3
Test Case - 2
User Output
Enter some text: Hello world! Hello John! Hello everyone!
Enter the word whose frequency is to be found: Hello
The frequency of word 'Hello' is: 3