/* Modifies LoanCalculator program. * The Principal and Rate are gotten from the user. * The program will output the monthly and total payments for 5,10,15,20,25,30 years. * * author Anthony Larrain * */ import javax.swing.JOptionPane; import java.text.NumberFormat; class LoanTable{ public static void main(String [] args){ final int MAX_YEARS = 30; int confirm; do{ double principal = Double.parseDouble(JOptionPane.showInputDialog( "Enter Amount you wish to borrow" )); double rate = Double.parseDouble(JOptionPane.showInputDialog( "Enter Annual interest rate (e.g. 6.5):")); for(int year = 5; year<= MAX_YEARS; year += 5){ Loan loan = new Loan(principal,rate,year); NumberFormat fmt = NumberFormat.getCurrencyInstance(); System.out.println(loan.toString()); System.out.println("Total Payments " + fmt.format(loan.totalPayment())); System.out.println(); } confirm = JOptionPane.showConfirmDialog( null, "Do Another Computation ?", "Confirmation Dialog", JOptionPane.YES_OPTION); }while(confirm == JOptionPane.YES_NO_OPTION); System.exit(0); } }