I am attempting to incorporate a 7 year loan as well as a 15 year loan into the following code and these two loans would have different interest rates than the 30 year loan I have already programmed. I need some assistance on how to incorporate a 7 year loan @ 5.35% and a 15 year loan @ 5.5% into my current code which compiles very nicely:

Date currentDate = new Date();
//Date Constructor
DecimalFormat decimalPlaces = new DecimalFormat("$0.00");

//Declaring Variables
double dPrincipal = 200000.00; //Total Loan or Principal Amount
double dInterest = .0575; //Interest Rate all Payments are Calculated at
double dTerm = 12*30; //Total Term of Loan in Months
double dMonthlyInterest = dInterest/12;

//Declaring Variables

final double dMonthly = dPrincipal * (dMonthlyInterest / (1 - Math.pow(1 + dMonthlyInterest,-dTerm)));
//The above formula calculates and determines the exact monthly payment based upon input

//The following code will display the output of the program
System.out.println("\t\t" + currentDate);
System.out.println("\t\tThe Total Loan Amount is: " + decimalPlaces.format(dPrincipal));
System.out.println("\t\tThe Calculated Interest Rate is: " + dInterest);
System.out.println("\t\tThe Total Number of Monthly Payments is: " + dTerm);
System.out.println("\t\tThe Total Monthly Payment is: " + decimalPlaces.format(dMonthly));

do you mean that for the fixed principal ( 200000 ), you have to show thw loan amount , interest rate, monthly payment for 30yrs, 15 yrs, 7 yrs resply.

for ( int i = 0 ; i < 3 ; i ++ )
{
//Declaring Variables
double dPrincipal = 200000.00; //Total Loan or Principal Amount
double dInterest = dInt [ i ]; //Interest Rate all Payments are Calculated at
double dTerm = 12* dTerms [i ]; //Total Term of Loan in Months
double dMonthlyInterest = dInterest/12;
//calculate and print
}

0

waw9667Author Commented:

Only a single payment for each loan term though. My current code shows what a $200,000 loan monthly payment would be on a 30 year loan at 5.75% interest rate. If you compile what I already have, I basically need to do the same exact thing for a 7 year loan at 5.35% interest rate and a 15 year loan at 5.5% interest rate. To answer your question,
yes. However, I already have the 30 year portion completed.

0

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

for ( int i = 0 ; i < 3 ; i ++ )
{
//Declaring Variables
double dPrincipal = 200000.00; //Total Loan or Principal Amount
double dInterest = dInt [ i ]; //Interest Rate all Payments are Calculated at
double dTerm = 12* dTerms [i ]; //Total Term of Loan in Months
double dMonthlyInterest = dInterest/12;

//Declaring Variables

final double dMonthly = dPrincipal * (dMonthlyInterest / (1 - Math.pow(1 + dMonthlyInterest,-dTerm)));
//The above formula calculates and determines the exact monthly payment based upon input

//The following code will display the output of the program
System.out.println("\t\t" + currentDate);
System.out.println("\t\tThe Total Loan Amount is: " + decimalPlaces.format(dPrincipal));
System.out.println("\t\tThe Calculated Interest Rate is: " + dInterest);
System.out.println("\t\tThe Total Number of Monthly Payments is: " + dTerm);
System.out.println("\t\tThe Total Monthly Payment is: " + decimalPlaces.format(dMonthly));

System.out.println( "" ) ;
}

have you tried this,

0

waw9667Author Commented:

Did I add something in the wrong place ? It contains three errors. I probably did.

Date currentDate = new Date();
//Date Constructor
DecimalFormat decimalPlaces = new DecimalFormat("$0.00");

//Declaring Variables
double dPrincipal = 200000.00; //Total Loan or Principal Amount
double dInterest = dInt[i]; //Interest Rate all Payments are Calculated at
double dTerm = 12*dTerms[i]; //Total Term of Loan in Months
double dMonthlyInterest = dInterest/12;
//Calculate and print

//Declaring Variables

final double dMonthly = dPrincipal * (dMonthlyInterest / (1 - Math.pow(1 + dMonthlyInterest,-dTerm)));
//The above formula calculates and determines the exact monthly payment based upon input

//The following code will display the output of the program
System.out.println("\t\t" + currentDate);
System.out.println("\t\tThe Total Loan Amount is: " + decimalPlaces.format(dPrincipal));
System.out.println("\t\tThe Calculated Interest Rate is: " + dInterest);
System.out.println("\t\tThe Total Number of Monthly Payments is: " + dTerm);
System.out.println("\t\tThe Total Monthly Payment is: " + decimalPlaces.format(dMonthly));

add one brace here,
public static void main(String[] args)
{

then one at the last,

System.out.println("\t\tThe Total Monthly Payment is: " + decimalPlaces.format(dMonthly));
}
}
}

0

waw9667Author Commented:

Thanks again for sharing your incredible knowledge and wisdom with a beginner like myself. I work in the IT field but this programming thing is just too new for me right now. Have a great day !!