public static void sentencesChecker(String essay) {

    int count = 0;

    int countcap = 0;

    int i , j;
    for ( i = 0; i < essay.length(); i++) {

        if (essay.charAt(i) == '.') {
       for ( char e= 'A'; e<='Z';e++) {
           if (essay.charAt(i)==e){




    System.out.print("\n\t\t" + countcap + "out of " + count + "sentences start with a capital letter");
1 Year
Discussion Span
Last Post by anand01

I see you failed to test this code, because it doesn't get anywhere near the stated functionality.
If you don't understand why try these test strings:

"This data has one sentence starting with a CAPITAL letter."
"this has none, says James."
"An ellipsis looks like this: ... .
"É is a latin capital letter E acute, Unicode: U+00C9, UTF-8: C3 89."
"What about this one? It has zero periods!"

.., ad that's without getting into what happens if any of the interesting characters are inside a quotation.

Listen: It's good that you are posting and contributing here, but for your own reputation you should be more careful about the quality of what you post.

Edited by JamesCherrill


Have you made any progress on testing your sentencesChecker(String essay) {.....} function as suggested by JamesCherrill?
Do you know how to test the your code?


Anu_6 ,
To find a sentences start with a capital letter read a first word of the sentence and check is start with upper case.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.