Is there an easy way for me to combine these two programs? What I am wanting to use an array for the different loans. Display the mortgage payment amount for each loan and then list the loan balance and interest paid for each payment over the term of the loan. Use loops to prevent lists from scrolling off the screen. Here are the two programs I have so far. Any guidance is appreciated.
*/
import java.io.*; // java input output package
import java.text.DecimalFormat; // allows placement of decimal
public class MonthlyPayments4e extends Thread //class header with "Thread" for sleep
{
public static void main(String[] args)
{
double Loan, NewBal, MIP;
double Rate, MonthlyInterest, Payments; //double precision variables
//assign values to variables
Loan= 200000; // loan amount
Rate = .0575; //interest rate
MonthlyInterest = Rate / 12; // interest for each month
Payments = Loan * (MonthlyInterest / (1 - Math.pow(1+MonthlyInterest, -360))); //my formula
DecimalFormat twoDigits = new DecimalFormat("$,000.00"); // declares decimal format
MIP= (Loan * Rate) / 12;
NewBal = Loan -(Payments-MIP);
System.out.println("Monthly Payments Interest Paid This Payment Loan Balance");
System.out.println();//my printout provides extra line
System.out.print(" " + twoDigits.format(Payments)); //my printout
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
while (NewBal > 1) //while loop to make computations continue until gets to $200000
{
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
if (NewBal <100000) // tells when this is met to transition to sleep phase
try
{
Thread.sleep (500); //sleep phase needed per change request also states pause is 500 milliseconds
}
catch (InterruptedException e)
{
}
}
}
}
*/
import java.io.*; // java input output package
import java.text.DecimalFormat;
public class MonthlyPayments5 //class header
{
public static void main(String[] args) //don't know if this is needed or not but here it is
{
double Loan;
double Rate1,Rate2,Rate3, MonthlyInterest1,MonthlyInterest2,MonthlyInterest3,Payment1,Payment2,Payment3; //double precision variables
//assign values to variables
Loan= 200000; // loan amount
Rate1 = 5.75;
Rate2 = 5.5;
Rate3 = 5.35;
MonthlyInterest1 = (Rate1 / 100) / 12;
MonthlyInterest2 = (Rate2 / 100) / 12;
MonthlyInterest3 = (Rate3 / 100) / 12;
Payment1 = Loan * (MonthlyInterest1 / (1 - Math.pow(1+MonthlyInterest1, -360))); //my formula
Payment2 = Loan * (MonthlyInterest2 / (1 - Math.pow(1+MonthlyInterest2, -180))); //my formula
Payment3 = Loan * (MonthlyInterest3 / (1 - Math.pow(1+MonthlyInterest3, -84))); //my formula
DecimalFormat twoDigits = new DecimalFormat("000.00");
System.out.println("\tYour Monthly Payments for 30 years are:\t $" + twoDigits.format(Payment1)); //my printout
System.out.println("\tYour Monthly Payments for 15 years are:\t $" + twoDigits.format(Payment2)); //my printout
System.out.println("\tYour Monthly Payments for 7 years are:\t $" + twoDigits.format(Payment3)); //my printout
}
}