I am trying to make a simple program that counts words, certain strings and sentences. I have the word counter and I have a counter that counts the certain strings but, I can not figure out how to count the sentences since essentially if I count all the decimals what if there is more than one " .".
so far this is my code..
int count = 0;
// while there is something in the file, keep reading and counting
while (inputFile.hasNext()) {
String token = inputFile.next();
count++;
}
int letters = 0;
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String nextToken = scanner.next();
if (nextToken.equalsIgnoreCase("for"))
{
letters++;
}
}