package loancalculation;
public class LoanCalculation
// Main method
public static void main(String[] args)
double annualInterestRate;
int numOfYears;
double loanAmount;
// Enter monthly interest rate
"Enter yearly interest rate, for example 8.25: ");
annualInterestRate = MyInput.readDouble();
// Obtain monthly interest rate
double monthlyInterestRate = annualInterestRate/1200;
// Enter number of years
"Enter number of years as an integer, for example 5: ");
numOfYears = MyInput.readInt();
// Enter loan amount
System.out.println("Enter loan amount, for example 120000.95: ");
loanAmount = MyInput.readDouble();
// Calculate payment
double monthlyPayment = loanAmount*monthlyInterestRate/
(1 - (Math.pow(1/(1 + monthlyInterestRate), numOfYears*12)));
double totalPayment = monthlyPayment*numOfYears*12;
// Display results
System.out.println("The monthly payment is " + monthlyPayment);
System.out.println("The total payment is " + totalPayment);
// Pause
System.out.println("Press Ctrl+C to close this window ...");

While pursuing a Computer Science degree, I founded, an online community for developers and IT professionals. I coded the backend platform from the ground up and I also do all of the advertising sales and SEO. I'm a super-geeky programmer with a passion for Internet marketing.