Payment Calculator help

• 07-04-2010, 12:07 AM
rpetronejr
Payment Calculator help
Trying to get a car loan calculator working, seems i have something wrong, its off by about 39 bucks. (20000 desired amount, .07 percent, 60 months). Guessing it has to be something easy but my mind is numb. Simple applet (user inputs price, rate and number of months), hits calculate button. Any guidance would be great.

Code:

```                public void actionPerformed(ActionEvent e)                 {                         double price = Double.parseDouble(costField.getText());                         double rate = Double.parseDouble(rateField.getText());                         double months = Double.parseDouble(monthsField.getText());                         i = (price * rate)/months;                         m = price/months;                         value = (i + m);                         outputLabel.setText("Monthly Payment is" + value);                         //outputLabel.setText("Monthly Payment is" + Math.round(value* 100)/100D);                 }```
• 07-04-2010, 12:20 AM
Norm
Try debugging your code by adding println()s to show all the results of all the calculations.

Put numbers in this to get algorithm to work.
Code:

```                        double price = 20000;                         double rate = 7.0;                         double months = 60;;                         double i = (price * rate)/months;                         double m = price/months;                         double value = (i + m);         System.out.println("value=" + value);  //value=2666.666666666667 v```
• 07-04-2010, 12:45 AM
rpetronejr
Understood, but seems i have something wrong with my formula's do they look ok to you? Or am i going crazy, but they seem right. But checking against a online calculator they dont appear to match up.
• 07-04-2010, 01:37 AM
Fubarable
Your monthly payment formula doesn't seem to match the one I've seen before: Mortgage calculator - Wikipedia, the free encyclopedia