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 7 of 7

Thread: LOOP ISSUSE

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Please Delete

    Delete Post!
    Last edited by OOO; April 25th, 2011 at 03:10 PM.


  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: LOOP ISSUSE

    Hi,

    This one is subtle and took me a minute or two of looking.

    There is a difference between

    i=+10 // Assigns the value 10 to i == (i = 10)

    and

    i += 10 // increments by 10

    This is the reason for the infinite loop.

    There is another bug with the program regarding the termination point.

    Suisse

  3. The Following User Says Thank You to SuisseToni For This Useful Post:

    OOO (April 2nd, 2011)

  4. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: LOOP ISSUSE

    Delete Post!
    Last edited by OOO; April 25th, 2011 at 03:04 PM.

  5. #4
    Junior Member
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: LOOP ISSUSE

    When you say…

    Quote Originally Posted by OOO View Post
    How can I change the loop or the formula so that the output is for every 10 minutes?
    what do you mean?

  6. #5
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: LOOP ISSUSE

    Delete Post!
    Last edited by OOO; April 25th, 2011 at 03:04 PM.

  7. #6
    Junior Member
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: LOOP ISSUSE

    Sorry I think I might have confused you. I mean that the for loop will terminate early the way you have written it.

    Have you Ran it since correcting the other issue?


    INPUT

    Please Enter Treadmill Type:
    a
    Please Enter Number of Minutes X:
    40


    OUTPUT

    Calories burned after 10 minutes : 39
    Calories burned after 20 minutes : 78
    Calories burned after 30 minutes : 117


    Your current for loop doesn't continue until 40.

    I am not trying to be difficult, but debugging skills are very important. Do you use an IDE or run the program from the command line?

    Suisse

  8. #7
    Junior Member
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: LOOP ISSUSE

    hi,

    im sorry for an interruption here in your post. Actually i wanted to post a new thread. and after i sign in and go to new posts , i dont find an option "post a new thread" anywhere .. could you please help me with that and where exactly i can do that..

    Thank you in advance ..

Similar Threads

  1. [SOLVED] My while loop has run into an infinite loop...?
    By kari4848 in forum Loops & Control Statements
    Replies: 3
    Last Post: March 1st, 2011, 12:05 PM
  2. Need help with loop
    By ciwas01 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 7th, 2011, 08:50 AM
  3. [SOLVED] Need help with while loop
    By anthony23415 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 6th, 2011, 03:23 PM
  4. for loop and while loop problems
    By Pulse_Irl in forum Loops & Control Statements
    Replies: 4
    Last Post: May 3rd, 2010, 02:09 AM
  5. hi. i want to rewrite this do loop into a while loop.
    By etidd in forum Loops & Control Statements
    Replies: 3
    Last Post: January 26th, 2010, 05:27 PM