Computer Science, asked by yashgangwaryash13, 1 year ago

Write a java program, which will read a text and count the occurrence of the word "the".For e.g.if the input is "The cat jumped over the fence". the output should be 2


bidisha496: hey....
bidisha496: @yashgangwaryash

Answers

Answered by bidisha496
0
Heymate!
Here's the answer.....

import java.io.*;
class the_counts
{
public static void main(String args [])throws IOException
{
InputStreamReader x=new InputStreamReader (System.in);
BufferedReader y=new BufferedReader(x);
int c=0;
String s="the",n,m;
System.out.print (Enter the sentence:);
n=y.readLine();
while (n!=0)
{
___________;
if (m==s)
c++;
}
System.out.print(c);
}
}

I hope it helps you....
Similar questions