/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package changerequest1;
import java.text.DecimalFormat;
/**
*
* @author Diane
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//create mortgage calculator
int years = 30; //define length of time variable
double mortgageAmount = 200000; //define total loan amount
int payments = years * 12; //define total payments over 30 years
double interestRate = 0.0575/12; //define the interenst rate of the loan
DecimalFormat decFor = new DecimalFormat("0.00"); //define decimal format
//loop to amortize loan
for (double i = payments; i>0;i--){
double monthlyPayment = (mortgageAmount * interestRate) / (1 - Math.pow(1 + interestRate,-payments));
double interest = mortgageAmount * interestRate;
double payment = monthlyPayment - interest;
double endingBalance = mortgageAmount - payment;
//print lines to display mortgage information
System.out.println ("Month " + (payments) + " Payment: " + decFor.format(monthlyPayment)); //displays month number and payment made
System.out.println ("Interest Paid: " + decFor.format(interest)); //displays interest paid
System.out.println ("Remaining Balance: " + decFor.format(endingBalance) + "\n\n"); //displays remaining balance
//loop for hesitation
if (payments > 0){
payments--;
try{
Thread.sleep(1500); //pause 1.5 seconds
}//end try
catch (InterruptedException e) {
//ignore or print the exception
}//end catch
}//end if
}//end for
}//end args
}//end program
Could someone please point me into the direction as to why the program is increasing the monthly payment please? Thank you

New Topic/Question
Reply



MultiQuote


|