I've been hammering away at this every free moment of my last week or two (I can't remember) and the project is due tonight. So I hope someone can provide some guidance soon. My mortgage calculator needs to list the total of interest payments for each month and I'm not sure how to proceed.
I need to somehow recalulate my principal and interest payments each month, replacing the original balance with the new balance in the formula. It must also pause occasionally during the listing to give the user a chance to look at the results. This is a non-GUI project as I am not yet that experienced in Java.
I stress that I am not looking for the answer, but some guidance as to what techniques to use, where to start looking for resources and perhaps an idea or two of how to apply them. Trust me, I will be sitting in front of this computer all day long trying to hammer it out myself until I have something that I can turn in.
Thanks, here is my code as it exists so far
CODE
/*
Title: Mortgage2.java
Writen by: Jim Blum
Date: 4/15/2007
Version: 2.0
Description: Modify the mortgage program to display the mortgage payment amount.
Then, list the loan balance and interest paid for each payment over
the term of the loan. The list would scroll off the screen, but use
loops to display a partial list, hesitate, and then display more of
the list. Do not use a graphical user interface.
Insert comments in the program to document the program.
*/
import java.util.Date;
import java.io.*;
import java.text.DecimalFormat;
public class Mortgage2
{
//Format Currency
static DecimalFormat currency = new DecimalFormat("$#,000.00");
//Declare Variables
static int iTerm = 360; //hardcoded mortage term in months
static double dBalance = 200000; //hardcoded mortage principal
static double dAPR = 5.75; //hardcoded Annual Percentage Rate (APR)
static double dMonthlyInterest = getMonthlyInterest();//Monthly interest rate
static double dPayment = getPayment();//Monthly payment
static double newBalance = getNewBalance();//Monthly balance after principal payment applied
static double dPrincipalPymnt = dBalance - newBalance; //Amount applied monthly to principal
static double dInterestPymnt = dPayment - dPrincipalPymnt; //Amount applied monthly to interest
//Date Constructor
static Date currentDate = new Date();
public static void main (String[] args) throws IOException
{
// Program Header
System.out.println();
System.out.println("\t\t\tMortage Calculator");
System.out.println("\t\t\tBy Jim Blum");
System.out.println("\t\t\tJava Programming");
System.out.println("\t\t\t" + currentDate);
System.out.println();
//Output Total Payment
System.out.println("The monthly payment on $200,000.00 at 5.75% APR is "+ currency.format(dPayment));
System.out.println();
System.out.println("New Balance "+ currency.format(newBalance) + "\t\tPrincipal = "+ currency.format(dPrincipalPymnt) +"\tInterest = "+ currency.format(dInterestPymnt));
System.out.println();
System.out.println();
} //end of main
public static double getMonthlyInterest()//calculates monthly interest based on APR
{
double dMonthlyInterest = dAPR / (12 * 100);
return dMonthlyInterest;
}//end of dMonthlyInterest method
public static double getPayment()//calculates monthly mortgage payment
{
double dPayment = (dBalance * getMonthlyInterest()) / (1 - Math.pow(1 + getMonthlyInterest(), - iTerm));
return dPayment;
}//end of getPayment method
public static double getNewBalance()//calculates new mortgage balance
{
double newBalance = dBalance * (1 + dMonthlyInterest) - dPayment;
return newBalance;
}//end of getNewBalance method
} //end of class