title: Looking for a way to keep two decimal places without rounding up
body: <p>I have to display my outputs with two decimal places and the program outputs should be 205.16 for monthly payment and 12309.91 for total payment. Before using decimal format to round the answers where correct but after rounding to two decimal places the outputs are now .01 to high. What can I do to remove the extra decimal places without rounding up .01?</p>
  
  <pre><code>import javax.swing.*;
  import java.text.*;
  
  
  /**
   *DriverMortgageClass
   */
  
  public class DriverMortgageClass
  {
      public double annualInterestRate;
      public int    numberOfYears;
      public double loanAmount;
      public double monthlyPayment;
      public double totalPayment;
      public double monthlyInterestRate;
  
      DecimalFormat fmt = new    DecimalFormat ("0.00");
  
      //main method
      public static void main(String[] args) {
          new DriverMortgageClass().start();
      }
  
      //declare private mortgage object
      private Mortgage mortgage;
  
      public DriverMortgageClass()
  
      {   
          mortgage = new Mortgage();
      }
      public void start()
      {
  
          //get input for interest rate
          String annualInterestRateString = JOptionPane.showInputDialog(null,"Enter yearly interest rate, for example 8.5",JOptionPane.QUESTION_MESSAGE);
          annualInterestRate=Double.parseDouble(annualInterestRateString);
          mortgage.setAnnualInterestRate(annualInterestRate);
  
  
          //get input for number of years
          String numberOfYearsString = JOptionPane.showInputDialog(null,"Enter number of years as an integer, for example 5",JOptionPane.QUESTION_MESSAGE);
          numberOfYears= Integer.parseInt(numberOfYearsString);
          mortgage.setNumberOfYears(numberOfYears);
  
  
          //set loan amount
          String loanAmountString = JOptionPane.showInputDialog(null,"Enter loan amount, for example 10000.00",JOptionPane.QUESTION_MESSAGE);
          loanAmount= Double.parseDouble(loanAmountString);
          mortgage.setLoanAmount(loanAmount);
  
  
          //Invoke monthly and total payment
          monthlyInterestRate=annualInterestRate/1200;
          monthlyPayment=loanAmount*monthlyInterestRate /(1-(Math.pow(1/(1+monthlyInterestRate),numberOfYears*12)));
          totalPayment=monthlyPayment*numberOfYears*12;
  
          //display monthly and total payment
          JOptionPane.showMessageDialog(null,"The monthly payment is"+ " " + fmt.format(monthlyPayment)+'\n'
                  +"The total payment is"+ " " + fmt.format(totalPayment));  
  
          System.exit(0);
      }
  }
  </code></pre>