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");
}
}
}