Need help with making this work. I can't get the System.format (prepayment) to work.

class Mortgage
{

 static NumberFormat fmat = NumberFormat.getCurrencyInstance();

    public static void main(String args[])
    {


      String input_amt =
      JOptionPane.showInputDialog("Enter loan amount: ");
      double loanAmount = Double.valueOf(input_amt).doubleValue();


     String input_rate   =
     JOptionPane.showInputDialog("Enter rate: ");
     double interestRate = Double.valueOf(input_rate).doubleValue();


     String input_term   =
     JOptionPane.showInputDialog("Enter term: ");
     int years = Integer.valueOf(input_term).intValue();

    String input_prepayment =   
    JOptionPane.showInputDialog( "Enter prepayment: ");
    double prepaymentAmt = Double.valueOf(input_prepayment).doubleValue();




     try
         {

     String message =
     String.format("Loan Amount:"+"  "+fmat.format(loanAmount)+"\n"+
     "Interest Rate:"+"  "+ interestRate +" %% \n"+
     "Term:"+"  "+years+" years\n\n")+"\n"+
     "Prepayment: "+" %%"\n";


      JOptionPane.showMessageDialog(null, message);
      }

          catch(NumberFormatException err)
          {
               System.out.println("Error Converting Number");
          }



    }
}

Edited 3 Years Ago by happygeek: fixed formatting

Multiple threads with the same question in less than a day means no answer for you. Figure it out on your own if it's that urgent.

This article has been dead for over six months. Start a new discussion instead.