Program to make frequency count of words in a given text



public class Frequency
{
public static void main(String[] args) 
{
String text,word;
int frequency=0;
System.out.println("Enter the text:");
text = System.console().readLine();
String[] t = text.split(" ");
System.out.println("Enter the word which frequency count want to check:");
word = System.console().readLine();
for(int i=0;i<t.length;i++)
{
if(t[i].equals(word))
{
frequency++;
}
}
System.out.println("Frequency count of the word '"+word+"' is: "+frequency);
}
}

OUTPUT:


Comments

  1. plz provide soft copy of java program number:6,24,32,35 to 48

    ReplyDelete

Post a Comment

Popular posts from this blog

HOW TO SETUP CODE BLOCKS FOR GRAPHICS PROGRAMS

Smile emoji using graphics in Java using Applet