1. Member
Join Date
Jul 2010
Posts
4
Rep Power
0

## 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.

Java 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);

}```

2. 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.
Java 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```
Last edited by Norm; 07-04-2010 at 01:26 AM.

3. Member
Join Date
Jul 2010
Posts
4
Rep Power
0
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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•