Results 1 to 3 of 3
  1. #1
    swilliams236 is offline Member
    Join Date
    Nov 2011
    Posts
    13
    Rep Power
    0

    Default Loop not working

    For some reason my loop will not, well loop. I just get the print out of the first value in the loop.

    Java Code:
            int counter;
            for(counter=1; counter<=yearToUse*12; counter++);{
            monthlyInterest = (balance*monthlyRate);
            if(counter == yearToUse*12){
                monthlyPayment = balance+monthlyInterest;}
            monthlyPrincipal = (monthlyPayment - monthlyInterest);
            balance = (balance - monthlyPrincipal);        
            System.out.println("Counter is " + counter + "Interest: " + 
                (nf.format(monthlyInterest)) + " Principal: " + (nf.format(monthlyPrincipal)) + " Balance: " + 
                (nf.format(balance)));
    Can someone help me? It's driving me crazy

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,759
    Rep Power
    7

    Default Re: Loop not working

    Take a very close look at line 2, the for statement. Can you see what should/should not be there?

  3. #3
    swilliams236 is offline Member
    Join Date
    Nov 2011
    Posts
    13
    Rep Power
    0

    Default Re: Loop not working

    Ahhhh! Thank you! That was driving me crazy, I took out the ; and it works perfect

Similar Threads

  1. for loop not working properly
    By lbgladson in forum New To Java
    Replies: 8
    Last Post: 10-15-2011, 12:33 AM
  2. Replies: 5
    Last Post: 11-27-2010, 03:49 AM
  3. Why isn't this while loop code working
    By GreenTea in forum New To Java
    Replies: 16
    Last Post: 11-10-2010, 03:14 AM
  4. while loop not working
    By RBNSN83 in forum New To Java
    Replies: 6
    Last Post: 06-21-2010, 07:29 AM
  5. Replies: 8
    Last Post: 05-28-2008, 07:00 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
  •