String response; response = JOptionPane.showInputDialog(null, "How many dollars do you wish to borrow?"); int dollars = (int) Double.parseDouble(response); //bollow money
response = JOptionPane.showInputDialog(null, "What is the interest rate?"); double rate = Double.parseDouble(response); //interest rate
response = JOptionPane.showInputDialog(null, "How many years will take the loan?(whole number)?"); int years = Integer.parseInt(response); //loan years
// begin the calculations
double totalInterest = calculateInterest();
DecimalFormat patternFormatter = new DecimalFormat("$###,##0.00"); JOptionPane.showMessageDialog(null, "If you loan " +patternFormatter.format(dollars)+" at an interest rate of " + rate +"\nfor" + years +" years, you must pay " +patternFormatter.format(totalInterest) +" in interest." );
System.exit(0); }//ends main method
public static double calculateInterest(int dollars,double rate,int years) {