Results 1 to 4 of 4
  1. #1
    rpetronejr is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default 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. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    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 12:26 AM.

  3. #3
    rpetronejr is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default

    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.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. need help with my calculator
    By semoche in forum AWT / Swing
    Replies: 6
    Last Post: 12-04-2009, 10:16 PM
  2. Calculator
    By water in forum AWT / Swing
    Replies: 4
    Last Post: 09-23-2009, 06:00 AM
  3. help with calculator
    By kalibballer in forum New To Java
    Replies: 8
    Last Post: 04-01-2009, 12:57 PM
  4. Calculator help.
    By madkidd02 in forum New To Java
    Replies: 2
    Last Post: 10-25-2008, 07:42 AM
  5. Swing Calculator
    By nemo in forum AWT / Swing
    Replies: 1
    Last Post: 05-28-2007, 11:07 AM

Posting Permissions

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