Thank you very much. I was really hoping for a brief description where I had // ???
Main Topics
Browse All TopicsMy program is complete and compiles very nicely. I am on an extremely beginner level and understand some things but most of the things I do, I simply know that I am supposed to do them but do not exactly understand the why nor can I put things into laman's terms to understand them better. Here is my program and I am asking for just brief explanations for better understanding of my program. I will put ??? by things I hope someone can better explain. Thanks a million !!
import java.io.*;
import java.lang.Math.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale; // Do I even need this or would java.lang.math be fine without this line ???
public class Mortgages
{
public static void main(String[] args)
{
DecimalFormat twoDigits = new DecimalFormat("$###,###.00
double mortgage = 200000.00;
double[][] yearsYearlyRate = //Multiplies term by interest rate
{
{ 7, 15, 30 },
{ 5.35, 5.5, 5.75 }
};
double[][] monthsMonthlyRt =
{
{
yearsYearlyRate[0][0] * 12, yearsYearlyRate[0][1] * 12,
yearsYearlyRate[0][2] * 12 // Provide brief description please
},
{
// ????? I understand the above but need some clarification of the (1200)
yearsYearlyRate[1][0] / 1200, yearsYearlyRate[1][1] / 1200,
yearsYearlyRate[1][2] / 1200
}
};
for (int i = 0; i < 3; i++) // brief descriotion please of what this means
{
// ??? Please help here
double payment = calPayment(monthsMonthlyRt
System.out.println("\nMort
System.out.println("$200,0
+ yearsYearlyRate[1][i] + "%\t\t" + twoDigits.format(payment))
System.out.println("\nPaym
interestBalanceList(mortga
}
}
// I totally do not understand what this entire double tmp or param thing means. Please help !!!
public static double calPayment(double param1, double param2, double mortgage) {
double tmp = 1 + ( param1 ) ;
for ( int i = 1 ; i < param2 ; i++)
tmp = tmp * ( 1 + param1 ) ;
double monthlyPayment = mortgage * tmp * param1 / ( tmp - 1 ) ;
// double monthlyPayment = (param1 + param2 / (Math.pow((1 + param1), param2) - 1)) * mortgage;
return monthlyPayment;
}
public static void interestBalanceList(double
double payment)
{
for (int i = 1; i < (param2 + 1); i++) // Provide brief description please
{
System.out.println("Press 'ENTER' to view the loan amortization.");
try
{
System.in.read(); // what exactly is this providing my program ??? Do I even need it ???
} catch (Exception e)
{
}
// Calculate the Monthly Interest of the Loan Balance
double monthlyInterest = mortgage * param1;
// Calculate the Remaining Loan Balance
double loanRemaining = mortgage - (payment - monthlyInterest);
// Set the value of Mortgage Amount to the Value of the Remaining Loan Balance
mortgage = loanRemaining;
// Format the Monthly Interest Amount into U.S. Currency
NumberFormat n = NumberFormat.getCurrencyIn
String str = n.format(monthlyInterest);
// Format the Remaining Loan Balance into U.S. Currency
NumberFormat num = NumberFormat.getCurrencyIn
String string = num.format(loanRemaining);
// Display the Payment #, Monthly Interest Paid and Remaining Loan Balance
System.out.println("\n " + i + "\t\t\t" + str + "\t\t\t" + string); // Please explain the string
}
} // Also, I would like to make the program pause after showing 12 payments on the screen so
// how would I go about doing this ?????
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
its a formula to calculate monthly payment amount.
1 + ( param1 ) = here param1 is monthly rate of interest. 1+, if you take loan of 100$ thn at the end of month you have to pay (1+rate of interest)*loan amount.
for ( int i = 1 ; i < param2 ; i++)
tmp = tmp * ( 1 + param1 ) ;
loop for no. of months for the loan duration.
mortgage formula double monthlyPayment = mortgage * tmp * param1 / ( tmp - 1 ) ;
Business Accounts
Answer for Membership
by: expertmbPosted on 2006-08-01 at 22:44:43ID: 17230565
import java.util.Locale; // Do I even need this or would java.lang.math be fine without this line ???
this line is required since pgm is referring locale for number format for currency.