Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Please help issue with a variable in a loop.

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help issue with a variable in a loop.

    In the following code the for loop variable rate learns its value from an if then statement based on the input of the user. I need to modify it within the loop to use the value of the input plus the loop counter. Any help would be appreciated. Here is the section of code in question.
    if(annual + loopcounter>=(.80 * target) && annual + loopcounter <= target)
    looprate = .05;
    else if(annual + looprate>= target)
    looprate = .05 + .125;

    for(loopcounter = 5000; (loopcounter + annual) < annual * 1.5;
    loopcounter +=5000)

    // Output for table
    System.out.println((annual+loopcounter) + " \t " +
    ((annual+loopcounter) * looprate + salary));


    looprate is only being based on the initial input of annual and not of annual+loopcounter.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Please help issue with a variable in a loop.

    Don't double post. Return to the first post and continue working it there.

Similar Threads

  1. While Loop Issue
    By greystreet34 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 30th, 2012, 09:55 PM
  2. For-loop: initialisation of variable, can't set variable to value zero?
    By Bitbot in forum Loops & Control Statements
    Replies: 4
    Last Post: July 15th, 2012, 02:32 PM
  3. Issue with PATH system variable
    By Melawe in forum The Cafe
    Replies: 12
    Last Post: December 29th, 2011, 08:07 AM
  4. Variable updates after loop
    By tecno40 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 9th, 2011, 05:34 AM
  5. issue with reading a clob variable from oracle
    By computerbum in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 28th, 2010, 06:08 PM

Tags for this Thread