title: how do you round up a double user input value in java?
body: <p>Im a student whos making a simple grading system and Im struggling on how to do this</p>
  <p>when I type in a specific number it go down to else bypassing my else-if statements
  the numbers are 98, 67, 98, 80 and 81 and i dont know why this happens</p>
  <p>Here's my code:</p>
  <pre><code>public static void main(String[]args) {
  
      double grade=0,tgrade=0,r;
      int gcount=0;
  
  
      for (int i = 0; i&lt;5;i++) {
  
          grade   = Integer.parseInt(JOptionPane.showInputDialog(null, &quot;Enter the grades &quot;));
          tgrade = tgrade+grade;
          gcount++;
          System.out.println(gcount+&quot;. &quot;+&quot;grade: &quot;+grade );
  
      }
      DecimalFormat c = new DecimalFormat(&quot;##.##&quot;);
      
      tgrade = tgrade/500*100;
      r = new Double(c.format(tgrade)).doubleValue();
      
      System.out.print(&quot;Total Grade: &quot;+(tgrade)+&quot;\n&quot;);
      if      (r &gt;= 95 &amp;&amp; r &lt;=100) {
          JOptionPane.showMessageDialog(null, &quot;High Honor&quot;);
      }else if (r &gt;= 90 &amp;&amp; r &lt;= 94){
          JOptionPane.showMessageDialog(null, &quot;Honor&quot;);
      }else if (r &gt;=85 &amp;&amp; r &lt;= 89) {
          JOptionPane.showMessageDialog(null, &quot;Good&quot;);
      }else if (r&gt;=80 &amp;&amp; r&lt;=84)   {
          JOptionPane.showMessageDialog(null, &quot;Satisfactory&quot;);
      }else if (r&gt;=75 &amp;&amp; r&lt;= 79) {
          JOptionPane.showMessageDialog(null, &quot;Low pass, but certifying&quot;);
      }else {
          JOptionPane.showMessageDialog(null, &quot;Low Failure&quot;);
      }
  }
  </code></pre>
  <p>}</p>