title: How format the output of decimal numbers via the JOptionPane
body: <p>My assignment asks me to format values to two decimal places. We are asked to use the JOptionPane for input/output. I know how to format to two decimal places using the System.out.printf. However, I don't think that would work, because we need to use the JOptionPane. </p>
  
  <p>If anyone could give me any advice on how to format it in a string (so I could then parse the string into a double), I'd appreciate it. Thanks.</p>
  
  <p>Here is my code as follows: </p>
  
  <pre><code>package Program4;
  import javax.swing.*;
  public class Program4 {
       public static void main (String[] args)
          {
           //Declaration of Variables
           Double AssessedValue;
           Double TaxableAmount;
           Double PropertyTax;
           Double TaxRatefor100 = 1.05;
           String StrAssessedValue;
           String OutputStr;           
           //Ask the user for the Assessed Value of their property
           StrAssessedValue = JOptionPane.showInputDialog("Enter the assessed " +
                  "value of your property: ");
           //Convert the string into a double
           AssessedValue = Double.parseDouble(StrAssessedValue);          
           //Calculations
           TaxableAmount = 0.92*AssessedValue;
           PropertyTax = (TaxableAmount/100)*1.05;             
           //Store the output in a string
           OutputStr = "Assessed Value: $" + AssessedValue + "\n" +
                   "Taxable Amount: $" + TaxableAmount + "\n" + 
                   "Tax Rate for each $100.00: $" + TaxRatefor100 + 
                   "\n" + "Property Tax: $" + PropertyTax;
           //Output the result         
           JOptionPane.showMessageDialog(null, OutputStr, "Property Tax Values",
                   JOptionPane.WARNING_MESSAGE);           
          }
  }
  </code></pre>