title: Interest Calculator truncation error in simple interest calculation (involving DecimalFormat)
body: <p>I wrote a program for an academic project that performs a simple interest and a compound interest calculation. The problem I am having is that the simple interest calculated is truncated if the number does not have something other than zero as the "cents" (i.e, it does not show the decimal points -- if the amount is for example 1750.00 it will show up as 1750) even though I used the DecimalFormat on both my methods for compound and simple interest!</p>
  
  <p>I have extensively debugged the project and I am really at a loss as to what the hell is going on.</p>
  
  <p>The relevant excerpt from the program is the following:</p>
  
  <pre><code>  double p=1.0; // just some sample values for p, r, and y.
    double r=2.0;
    double y=3.0;
    double calculatedInterest = p + (p*(r/100)*y);
    String output = new String("Computed Simple Interest is: $");
    output = output + new DecimalFormat("#.##").format(calculatedInterest);
    return output;
  </code></pre>
  
  <p>I have the full program here:</p>
  
  <p><a href="http://pastebin.com/sgg0P5ZQ" rel="nofollow">http://pastebin.com/sgg0P5ZQ</a></p>
  
  <p><strong>[EDIT] Moral of the story</strong>: If you don't read the JavaDoc of a class you are having issues with or don't understand, you are going to have a bad time. The symbolic pattern #.## is not just the universal catch-all for the DecimalFormat, different symbol patterns do different things. In my case, what was necessary was to change the #.## to 0.00 in order to see the decimal numbers that I desired. Much thanks to jpe.</p>