public class StringSearcher
{
public static void main (String[] args)
{
java.util.Scanner userInput = new java.util.Scanner(System.in);
String sentence = new String();
String searchword = new String();
int sentenceLength;
int wordLength;
int wordIndex;
int total = 0;
int index;
index = sentence.indexOf(" ");
while(index != -1)
{
total++;
index = sentence.indexOf("searchword", index + 1);
}
System.out.println("Enter a sentence.");
sentence = userInput.nextLine();
System.out.println("Now enter a search word.");
searchword = userInput.nextLine();
System.out.println("Your sentence had the search word "+searchword+"+total+" times");
}
}