0

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 by happygeek: fixed formatting

2
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by LoLo
0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.