title: Java format modifiers doubles in string
body: <p>I received an assignment at university in Java where I have to use <code>printf</code> to format output to the console. It was all nice and dandy but for some reason I am getting the output <code>10500.000000000002</code>, the right output should be <code>10500.00</code>. I tried to use the <code>%0.2f</code>, but because I formatted in a <code>String</code> I cannot do it.</p>
  
  <p>This is the line in question:</p>
  
  <pre><code>System.out.printf("\nAge Depreciation Amount:%66s","$"+ ageDepreciationAmount);
  </code></pre>
  
  <p>Can you please suggest a way to format this properly? Please keep in mind this is an introductory course to java, which means I am a complete disaster when it comes to programming.</p>