Write the program in Java (without a graphical user interface) using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term. Display the mortgage payment amount and then list the loan balance and interest paid for each payment over the term of the loan. If the list would scroll off the screen, use loops to display a partial list, hesitate, and then display more of the list.
It runs but... it doesn't subtract the amount to $0.00
if someone can take a look and help me out, that would be Great!
Thanks.
CODE
import java.util.*;
import java.text.*;
public class mortgage2
{
public static void main(String[]args)
{
// declare variable
System.out.println("Mortgage1\n");
double loan=200000.00;// P
double term=30; // L
double interest=5.75; //I
double monthly_payment= 0; //M
double monthly_interest= 0; //J
double months; //N
double Current_Monthly_Interest_Rate = 0; // H
double Principal_Paid_Current_Month = 0; //C
double New_Balance_Of_Principal = 0; //Q
int linecounter = 30;
//Displays the mortgage calculator
System.out.println("Mortgage Calculator");
System.out.println("The loan amount is $200,000");
System.out.println("The term of the loan is 30 years");
System.out.println("The interest rate applied to the loan is 5.75%");
System.out.println();
{
// calculate monthly interest
monthly_interest=interest/(12*100); //J
System.out.println("monthly_interests: " + monthly_interest);
// calculate months
months=term*12; //N
System.out.println("month: " + months);
// calculate monthly payment
monthly_payment=monthly_interest*loan/
(1-Math.pow( (1+monthly_interest), -months) );
// display monthly payment
System.out.println("\n\n\t Monthly Payment is: " + monthly_payment);
System.out.println();
for (int k =1; k<=360; k++)
{
Current_Monthly_Interest_Rate = (loan * monthly_interest);
System.out.println("Current: " +Current_Monthly_Interest_Rate);
Principal_Paid_Current_Month =(monthly_payment - Current_Monthly_Interest_Rate);
System.out.println("Principal: " +Principal_Paid_Current_Month);
New_Balance_Of_Principal =(loan - Principal_Paid_Current_Month);
System.out.println("new balance: " +New_Balance_Of_Principal);
//display current payment information.
System.out.println("Month= " +k+ "\tBalance = "+
New_Balance_Of_Principal + " interest = " + Current_Monthly_Interest_Rate);
linecounter++;
if(linecounter ==15)
{
for(int i=1;i<10000;i++)
for(int j=1;j<1000000; j++);
linecounter=0;
System.out.println();
loan = New_Balance_Of_Principal;
}
}
}
}
}
~edit: added code tags PBThis post has been edited by PennyBoki: 24 Jan, 2008 - 10:48 AM