title: Wrong calculations
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cs50.h&gt;
  #include &lt;string.h&gt;
  #include &lt;math.h&gt;
  
  int letters = 0;
  int words = 0;
  int sentences = 0;
  
  int main(void)
  {
      string text = get_string(&quot;Text: &quot;);
      printf(&quot;\n&quot;);
      
      for(int j = 0; j &lt; strlen(text); j++)
      {
          if((text[j] &gt;= 'a' &amp;&amp;  text[j] &lt;= 'z') || (text[j] &gt;= 'A' &amp;&amp; text[j] &lt;= 'Z'))
          {
              letters++;
          }
          
          if(text[j] == ' ')
          {
              words++;
              
          }
          
          if(text[j] == '.' || text[j] == '?' || text[j] == '!')
          {
              sentences++;
          }
      }
      printf(&quot;Letters: %i\n&quot;, letters);
      printf(&quot;Words: %i\n&quot;, words + 1);
      printf(&quot;Sentences: %i\n&quot;, sentences);
      
      float L = ((float)letters / (float)words) * 100;
      float S = ((float)sentences / (float)words) * 100;
      float result = round(0.0588 * L - 0.296 * S - 15.8);
      printf(&quot;%f\n&quot;, L);
      printf(&quot;%f\n&quot;, S);
         printf(&quot;%f\n&quot;, result);
      
      
      if(result &lt; 1)
      {
          printf(&quot;Before Grade 1&quot;);
      }
      if(result == 1)
      {
          printf(&quot;Grade 1&quot;);
      }
      if(result == 2)
      {
          printf(&quot;Grade 2&quot;);
      }
      if(result == 3)
      {
          printf(&quot;Grade 3&quot;);
      }
      if(result == 4)
      {
          printf(&quot;Grade 4&quot;);
      }
      if(result == 5)
      {
          printf(&quot;Grade 5&quot;);
      }
      if(result == 6)
      {
          printf(&quot;Grade 6&quot;);
      }
      if(result == 7)
      {
          printf(&quot;Grade 7&quot;);
      }
      if(result == 8)
      {
          printf(&quot;Grade 8&quot;);
      }
      if(result == 9)
      {
          printf(&quot;Grade 9&quot;);
      }
      if(result == 10)
      {
          printf(&quot;Grade 10&quot;);
      }
      if(result == 11)
      {
          printf(&quot;Grade 11&quot;);
      }
      if(result == 12)
      {
          printf(&quot;Grade 12&quot;);
      }
      if(result == 13)
      {
          printf(&quot;Grade 13&quot;);
      }
      if(result == 14)
      {
          printf(&quot;Grade 14&quot;);
      }
      if(result == 15)
      {
          printf(&quot;Grade 15&quot;);
      }
      if(result &gt;= 16)
      {
          printf(&quot;Grade 16+&quot;);
      }
      printf(&quot;\n&quot;);
  }
  </code></pre>
  <p>Text:</p>
  <pre><code> Congratulations! Today is your day. You're off to Great Places! You're off and away!
  </code></pre>
  <p>Result:</p>
  <pre><code>Letters: 65
  Words: 14
  Sentences: 4
  500.000000
  30.769232
  4.000000
  Grade 4
  </code></pre>
  <p>I need to calculate the '0.0588 * L - 0.296 * S - 15.8' formula in my code, but for some reason, it is giving me the wrong answer for some text and right for some text. in this particular example, it should give me 'Grade 3' but it is giving me 'Grade 4' instead and if I put a text for grade 10 it will give me 'Grade 10'. And the calculations for 'L' and 'S' are wrong, in this example, they should be L = 464.29 and S = 28.57. I really don't know where I am going wrong, can someone please help me?</p>