I'm trying to get this program to calualte the totals of 3 different mortgages using arrays.I need the program to calculate the loans to the end of each term. Can someone point me in the right direction, before I lose my mind!
Code:
import java.math.*;
import java.text.DecimalFormat;
import java.util.*;
public class mortgage3Loanswk5
{
public static void main(String[]args)
{
//Declare varibles//
double mortgage1, mortgage2, mortgage3, ammount;
ammount= 200000;//Principle loan//
double monthlyRate1, monthlyRate2, monthlyRate3;
double[] iRate= {0.0575, 0.0550, 0.0535};//interest rates on 3 loans//
int[] term= {30, 15, 7};//number of years for loans//
double MP=(0);
int year= (0);
int month= (0);
int NewInterest1= (0);
int NewInterest2= (0);
int NewInterest3= (0);
int amount1= 200000;
int amount2= 200000;
int amount3= 200000;
double interest1= 0.0575;
double interest2= 0.055;
double interest3= 0.0535;
double []payment={(monthlyRate1), (monthlyRate2), (monthlyRate3)};
double []interest={(interest1), (interest2), (interest3)};
String hold="";
Scanner scan=new Scanner(System.in);
DecimalFormat decimalPlaces=new DecimalFormat("0.00");
//Formulas used within this program//
monthlyRate1=(ammount*((iRate[0]/12)/(1-Math.pow((1+(iRate[0]/12)),-(term[0]*12)))));
interest1= amount1*(interest1/12);
loanamount1=(interest1+amount1)-(monthlyRate1));
monthlyRate2=(ammount*((iRate[1]/12)/(1-Math.pow((1+(iRate[1]/12)),-(term[1]*12)))));
loanamount2=((interest2+amount2)-monthlyRate2);
interest2=(amount2*(interest2/12));
monthlyRate3=(ammount*((iRate[2]/12)/(1-Math.pow((1+(iRate[2]/12)),-(term[2]*12)))));
interest3=(amount3*(interest3/12));
loanamount3=((interest3+amount3)-monthlyRate3);
double []newmonthly={(loanamount1), (loanamount2), (loanamount3)};
//loop begins here//
for(year=1; year<=term[0]; year++)
{
System.out.println();
System.out.println("Press\"Enter\"to continue.");
hold=scan.nextLine();
{
}
}
System.out.println("The interest of the loan is: "+iRate[0]*100+"%");
System.out.println("Monthly Payments for the 1st is:$" +decimalPlaces.format(monthlyRate1));
System.out.println("The term of the loan is:"+term[0]+"years{"+term[0]*12+"months}");
System.out.println("");
System.out.println("The interest of the loan is: "+iRate[1]*100+"%");
System.out.println("Monthly Payments for the 2nd loan is:$" +decimalPlaces.format(monthlyRate2));
System.out.println("The term of the loan is:"+term[1]+"years{"+term[1]*12+"months}");
System.out.println("");
System.out.println("The interest of the loan is: "+iRate[2]*100+"%");
System.out.println("Monthly Payments for the 3rd loan is:$" +decimalPlaces.format(monthlyRate2));
System.out.println("The term of the loan is:"+term[2]+"years{"+term[2]*12+"months}");
System.out.println("");
}
}//End program//
Comment