Results 1 to 9 of 9
  1. #1
    grunt9800 is offline Member
    Join Date
    Mar 2017
    Posts
    6
    Rep Power
    0

    Default If-statement not working

    deleted
    Last edited by grunt9800; 03-11-2017 at 08:27 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: If-statement not working

    Would an annual interest rate which is less than 1.0 every be greater than a monthly payment? Check your math
    and the units you are comparing.


    And once you print out that message, what do you do? You continue on executing the program.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    grunt9800 is offline Member
    Join Date
    Mar 2017
    Posts
    6
    Rep Power
    0

    Default Re: If-statement not working

    deleted
    Last edited by grunt9800; 03-11-2017 at 08:27 PM.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: If-statement not working

    Well, your interest rate is a percentage so it's less than 1. But even if you don't divide by 100 does it really make sense to compare
    a percentage amount to a monthly payment? So you need to figure out what to compare. You can also use an if/else construct to control
    executing parts of your code.

    And you can use a loop to repeatedly reprompt for the numbers.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    grunt9800 is offline Member
    Join Date
    Mar 2017
    Posts
    6
    Rep Power
    0

    Default Re: If-statement not working

    deleted
    Last edited by grunt9800; 03-11-2017 at 08:27 PM.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: If-statement not working

    Well, one can presume the interest rate is fixed. Now payment schedules are not as straight forward as simple interest but let's say the interest rate is 10 percent on a $1100 loan. so that means I would pay $100 at the beginning of each year. So I make a payment and I now owe $1000. Next year I will owe
    $1100 ($1000 x 1.10). So I make a new $100 payment. Basically I am only paying the interest and not making a dent in the principal. So any payment I make must exceed the interest charged or I will never pay off the loan.

    So you have to calculate an interest amount per unit time. So if the unit time is one month, then I must pay at least that much each month.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    grunt9800 is offline Member
    Join Date
    Mar 2017
    Posts
    6
    Rep Power
    0

    Default Re: If-statement not working

    deleted
    Last edited by grunt9800; 03-11-2017 at 08:27 PM.

  8. #8
    grunt9800 is offline Member
    Join Date
    Mar 2017
    Posts
    6
    Rep Power
    0

    Default Re: If-statement not working

    deleted
    Last edited by grunt9800; 03-11-2017 at 08:28 PM.

  9. #9
    grunt9800 is offline Member
    Join Date
    Mar 2017
    Posts
    6
    Rep Power
    0

    Default Re: If-statement not working

    deleted
    Last edited by grunt9800; 03-11-2017 at 08:28 PM.

Similar Threads

  1. If statement not working right
    By Andrew_3ds in forum New To Java
    Replies: 5
    Last Post: 10-02-2013, 09:21 AM
  2. Why is my if statement not working.
    By OverRatedProgrammer in forum New To Java
    Replies: 4
    Last Post: 08-23-2013, 04:31 AM
  3. Why isn't this if statement working?
    By ocomobock in forum New To Java
    Replies: 3
    Last Post: 03-27-2012, 02:13 AM
  4. 'if' statement not working?
    By Etimer in forum New To Java
    Replies: 4
    Last Post: 03-10-2012, 05:18 AM
  5. if statement with strings not working... again
    By hardcorebadger in forum New To Java
    Replies: 4
    Last Post: 01-11-2011, 06:02 AM

Tags for this Thread

Posting Permissions

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