For my class assignment, we are making a mortgage calculator. Our first assignment allowed the user to enter the amount, the term, and the interest. For this assignment, we are to use the JComboBox to allow the user to select from a 7, 15, and 30 year loan, and the interest rates are to be associated with each selection.
I am not quite sure how to assign the interest rate to the term selections, and how to pass that value on for calculation. We are also suppose to have a table show the entire loan with monthly payments, interest rates, and balance after each month. I am more concerned with getting the combo box working for now. If anyone can give me any advice I would greatly appreciate it.
Here is the section of code from my last program for the calculations. The term select portion is what I need to change, as well as configure the combo box. Let me know if you guys need more from me.
private void computePayActionPerformed(java.awt.event.ActionEvent evt) {//event_computePayActionPerformed
// calculate the monthly payment
double p=Double.parseDouble(amount.getText());
double r=Double.parseDouble(rate.getText())/100;
double n=Integer.parseInt(term.getText());
// this formula was borrowed from Desiree
double monthPayment = ((p * r / 12 * Math.pow(r / 12 + 1,n*12))/(Math.pow(r/12+1,n*12)-1));
DecimalFormat df = new DecimalFormat("$###,###.00");
display.setText(df.format(monthPayment));
Question
dub40
For my class assignment, we are making a mortgage calculator. Our first assignment allowed the user to enter the amount, the term, and the interest. For this assignment, we are to use the JComboBox to allow the user to select from a 7, 15, and 30 year loan, and the interest rates are to be associated with each selection.
I am not quite sure how to assign the interest rate to the term selections, and how to pass that value on for calculation. We are also suppose to have a table show the entire loan with monthly payments, interest rates, and balance after each month. I am more concerned with getting the combo box working for now. If anyone can give me any advice I would greatly appreciate it.
Here is the section of code from my last program for the calculations. The term select portion is what I need to change, as well as configure the combo box. Let me know if you guys need more from me.
Link to comment
Share on other sites
17 answers to this question
Recommended Posts