title: How to remove trailing zero from a double?
body: <p>My program is supposed to calculate change:</p>
  
  <pre><code>double purchaseAmount = Double.parseDouble(s1);
  double amountGiven = Double.parseDouble(s2);
  double change = purchaseAmount - amountGiven;
  JOptionPane.showMessageDialog(null, change);
  
  String result = "Change consists of:";
  </code></pre>
  
  <p>My change is counted in bills and coins. But once I get to the coins, which are double:</p>
  
  <pre><code>double quarters = 0;
  if (change &gt;= .25) {
      quarters = change / .25;
      change = change - quarters * .25;
      result = result + quarters + "quarters";
      change = change - quarters % .25;
  }
  </code></pre>
  
  <p>The result is giving me a trailing .0  for instance instead of telling me my change is 1 twenty 2 quarters. I get 1 twenty 2.0 quarters. I've tried almost everything, <code>BigDecimal</code>, <code>NumberFormat</code> <code>DecimalFormat(##.###)</code> I already have a String in the program and would not know how to add another.</p>