/** * Loan Payment Calculator * @author Jenny Orr * @version Sept 9, 2013 */ public class LoanPaymentApp { public static void main(String[] args) { // Inputs double loanAmount = 5000.0; // in dollars double interestRate = 5.0; // yearly rate in percent double loanLength = 10.0; // in years double monthlyInterestRate = interestRate/100./12; double loanLengthMonths = loanLength*12; System.out.println("**** The Loan Payment Calculator **** "); System.out.println("Loan Amount: $" + loanAmount); System.out.println("Yearly Interest Rate: " + interestRate + "%"); System.out.println("Loan Length: " + loanLength + " years"); // Formula taken from http://www.mtgprofessor.com/formulas.htm double temp = Math.pow( 1.0 + monthlyInterestRate, loanLengthMonths); double payment = loanAmount * monthlyInterestRate* temp / ( temp - 1.0); //System.out.println("Your monthly payment will be $" + payment); // Or written with better formatting: System.out.printf("\nYour monthly payment will be $%.2f\n",payment); } }