I need help in figuring out how to make the code for sentences by determining that there is ., ?, ! in the sentence at the end. And the paragraph where you find each paragraph by the spaces between the lines. If you could just help me start, I'll finish it...

scanner = new Scanner(new File("C://README.txt"));
while (scanner.hasNext())
{
String input = scanner.nextLine();
StringTokenizer tokenizer = new StringTokenizer(input);
charCount = charCount + input.length();
lineCount = lineCount + 1;

while (tokenizer.hasMoreTokens())
{
word = tokenizer.nextToken();
wordCount = wordCount + 1;


for( int i = 0; i < input.length(); i++ )
{
if( Character.isLetter(input.length()) == true )
{
charPerWordCount = charPerWordCount + 1;
}
}//end Character Per Word

for( int k = 0; k < input.length(); k++ )
{
if( Character.isWhitespace('\r') == true )
{
paragraphCount = paragraphCount + 1;
}
}// end Paragraph

}//end StringTokenizer
}// end Scanner
scanner.close();

// print out statistics
System.out.println( "Page count: " + lineCount/60 );
System.out.println( "Word count: " + wordCount );
System.out.println( "Line Count: " + lineCount );
System.out.println( "Character count: " + charCount );
System.out.println( "Character per word count: " + charPerWordCount );
System.out.println( "Sentence count: " + sentenceCount );
System.out.println( "Paragraph count: " + paragraphCount );
}
}//end TextFileStats.java

Member Avatar for iamthwee

>If you could just help me start, I'll finish it..
So you have your ideas, now put them into practise.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.