I have been struggling with Week 2 Problem Set 2 Readability Question. At this point, I feel like I am stuck, and spend too much time just trying to fix one error. The code works perfectly except "Grade 8". For Letters, Words and, Sentences, I get the correct output always. Expect "Grade 8" and only on a specific paragraph. Every other grade comes perfectly true. I checked it with debugging tool and tried check50 as well and it gives an error in the expected grade 8 examples. I think there is a middle ground in the index function and I can't get out of it.
"Grade 8: "
Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice "without pictures or conversation?"
The output after the Coleman-Liau index comes
Grade float: 7.403509.
Rounded Grade: 7 Expected: 8
The index function:
float L = (float)letters / (float)words * 100; // Average number of letters per 100 words float S = (float)sentences / (float)words * 100;// Average number of sentences per 100 words float index = 0.0588 * L - 0.296 * S - 15.8; return index;
float gradi = grade(letters, words, sentences); // Call function int grad = round(gradi); // round the float save as int
Then I go to print functions.
Does anyone have any idea what I am doing wrong? The only error I get is from Grade 8 and I am burned out right now.