I need help with this Java program for school. I have to add loops so that each loan will loop and show the payment made, the int payment made, and the loan balance for each month of the entire loan. There are three different loans, 7 year, 15 year, and 30 year. Each with a different interest rate. I have that part done, just need to figure out how to put the loops in to show each months payment and ending loan balance. I've tried do/while, for, and if/else, and I can't get any of them to work. Can someone please help me?
import java.io.*;
import java.util.Arrays;
public class MortgageCalculator
{
public static void main(String[] args) throws Exception
{
//Assign variables for principal amount
double principal = 200000; //Principal amount of the loan is $200,000
double PrinAmt1, PrinAmt2, PrinAmt3; //Assign 3 different principal amounts
double Payment1, Payment2, Payment3; //Assign 3 different payment amounts
double Int1, Int2, Int3; //Assign 3 different interest rate amounts
double moPrin1, moPrin2, moPrin3; //Assign 3 different monthly principal payment amounts
double LoanBal = 0;
PrinAmt1 = principal;
PrinAmt2 = principal;
PrinAmt3 = principal;
moPrin1 = 0;
moPrin2 = 0;
moPrin3 = 0;
Int1 = 0;
Int2 = 0;
Int3 = 0;
int IntCounter = 0;
//Term of Loan Array
int [] Term = {84, 180, 360}; //Loan years * 12
//Interest Rate Array
double [] Rate = {0.0535, 0.055, 0.0575};
//Loan Amount Array
double [] LoanAmt = {200000, 200000, 200000};
//Each payment calculation
Payment1 = (principal * Rate [0] / 12)/(1-1/Math.pow((1+Rate[0]/12), Term[0]));
Payment2 = (principal * Rate [1] / 12)/(1-1/Math.pow((1+Rate[1]/12), Term[1]));
Payment3 = (principal * Rate [2])/ 12/(1-1/Math.pow((1+Rate[2]/12), Term[2]));
//Print to screen Loan - Amount, Years, Interest rate and monthly payment for a 7-year loan.
do{
IntCounter = IntCounter ++; //Add one to payment # for each month
Int1 = PrinAmt1 = Payment1 * Int1; //Monthly Interest payment
Payment1 = Payment1 - Int1; //Principal payment
PrinAmt1 = PrinAmt1 - Payment1; //Principal minus one payment
System.out.println("Loan Amount: $200,000.00");
System.out.println("Term: 7 Years");
System.out.println("Interest Rate 5.35%");
System.out.printf("Monthly payment amount is $%.2f\n", Payment1);
}while (PrinAmt1 >= 0);
do{
IntCounter = IntCounter ++; //Add one to payment # for each month
Int2 = PrinAmt2 = Payment2* Int2; //Monthly Interest payment
Payment2 = Payment2 - Int2; //Principal payment
PrinAmt2 = PrinAmt2 - Payment2; //Principal minus one payment
System.out.println("\nLoan Amount: $200,000.00");
System.out.println("Term: 15 Years");
System.out.println("Interest Rate 5.5%");
System.out.printf("The monthly payment amount is $%.2f\n", Payment2);
System.out.println( );
}while (PrinAmt2 >= 0);
do{
IntCounter = IntCounter ++; //Add one to payment # for each month
Int3 = PrinAmt3 = Payment3 * Int3; //Monthly Interest payment
Payment3 = Payment3- Int3; //Principal payment
PrinAmt3 = PrinAmt3 - Payment3; //Principal minus one payment
System.out.println("Loan Amount: $200,000.00");
System.out.println("Term: 30 Years");
System.out.println("Interest Rate 5.75%");
System.out.printf("Monthly payment amount is $%.2f\n", Payment3);
System.out.println( );
}while (PrinAmt3 >= 0);
}
}