title: JAVA OptionPane.showMessageDialog output formatting for decimal
body: <p>I am very new to Java and playing with displaying a message with GUI. So if use the console </p>
  
  <pre><code>System.out.printf("Your total montly bill is $%.2f",  totalCost); 
  </code></pre>
  
  <p>gives me the output with decimal the way it should. I am trying to do the same thing with this, but I get more digits after the decimal because totalCost is a type double. How can I format the output to only show two digits after the decimal? Thanks.</p>
  
  <pre><code>JOptionPane.showMessageDialog(null, "Your monthly payment is " + totalCost);
  </code></pre>