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

Thread: Keeping Track

  1. #1
    Member
    Join Date
    Jan 2012
    Posts
    65
    My Mood
    Happy
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Keeping Track

    How would you keep track of how many times a program has ran through a loop? For example, program asks user to continue (y/n), if they enter y, program continues then asks again once finished with task (continue? (y/n)). If n, then program ends. I want to keep track of how many times the user has entered y to continue the program, so I can record how many attempts they have made and then print out the number of attempts after the user quits.


  2. #2
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: Keeping Track

    Just create an integer variable that is incremented every time the loop is completed.

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

    Nuggets (April 15th, 2012)

  4. #3
    Member
    Join Date
    Jan 2012
    Posts
    65
    My Mood
    Happy
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Re: Keeping Track

    So simple. Sometimes asking a question will help my brain ignite to solve a problem. Thanks for responding.

Similar Threads

  1. keep track of objects
    By keep smiling in forum Java Theory & Questions
    Replies: 4
    Last Post: February 20th, 2012, 03:44 PM
  2. [SOLVED] Help with keeping the gui one size
    By derekxec in forum AWT / Java Swing
    Replies: 3
    Last Post: July 27th, 2011, 02:43 PM
  3. keeping track of array taht holds object
    By jack_nutt in forum Java Theory & Questions
    Replies: 1
    Last Post: June 20th, 2011, 11:17 PM
  4. Applying a MIDI instrument change to a Track
    By AnkleSpankle in forum Java Theory & Questions
    Replies: 3
    Last Post: January 23rd, 2011, 03:34 PM
  5. Track the user session list
    By kalees in forum Java Servlet
    Replies: 3
    Last Post: October 24th, 2009, 02:34 PM