Megalodeez 0 Newbie Poster

Write a program that calculates and displays the mortgage payment
Also list the loan balance and interest paid for each payment over a the term of loan. Use loops to display a partial list, hesitate and display more of the list.

Im completely lost. any help will be much appreciated. Im desperately trying to understand the material. Once you run the code, you will see how far Im off.

import java.util.Scanner;
import java.io.*;

public class Mortgage
{


public static void main(String[] args) throws IOException
{


	 double interestIPay;
	 double goToPrincipal;
	 double newBalance;
	 double principal;

	double term;
	double balance;
	double rate;
	double monthly_payments;
	double n;
	double i;

	 term = 0;
	 balance = 0;
	 rate = 0;
	 monthly_payments = 0;




Scanner key = new Scanner(System.in);
System.out.println("\t\tMortgage Payment Calculator");

System.out.println("What is your Principal?");
balance = key.nextDouble();

System.out.println("What is your interest rate?");
rate = key.nextDouble();

System.out.println("What is your term?");
term = key.nextInt();

      n = (term * 12);

	  i = (rate /100/12);

	  monthly_payments = balance * (i *Math.pow((1+i),n))/(Math.pow((1+i),n)-1);



System.out.println("\t\tBalance owed is " + balance);
System.out.println("\t\tYearly interest rate is " + rate);
System.out.println("\t\tThe length of loan is " + term + " years");
System.out.println("\t\tYour monthly payment " + monthly_payments);



for ( i =1; i<=term*12; i++)
{
	  interestIPay = balance * rate;
	  goToPrincipal = monthly_payments - interestIPay;
	  newBalance = balance - goToPrincipal;
	  balance = newBalance;

	  System.out.println("Interest You Pay" + interestIPay);
	  System.out.println(goToPrincipal + "Goes to Principal");
	  System.out.println(newBalance + "Is Your new Balance");
	  System.out.println("Your Balance: " + balance);

}
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.