Results 1 to 5 of 5
  1. #1
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Question Loop, is it what I need?

    I have a program that writes to a .txt file, enter data into several fields, do a calculation then add it to the file where some of the fields are saved.

    I want to restrict the number of members to add to the file, say 3 until I get it working, is it a do while loop that is the best for this? or just a while loop? or am I going in completely the wrong direction?

    Thanks in advance

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    members? Perhaps a clarification of terms and concepts will help us here.

  3. #3
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Default

    Think of it as a gym, the member types in there membership number, age, gender etc, then their height and weight, output is there bmi, several of these fields are saved to a txt file, now I want to restrict it that once the new file has been created that you can only add a certain number of members, for testing purposes say 3 and once you have entered the third member the button is disabled and wont let you add any more.

    I know how to disable the button but I cant seem to get the loop working and so got to wondering whether this was the best thing before I spend any more time on it.

    Thanks in advance

  4. #4
    Mr.Beans's Avatar
    Mr.Beans is offline Senior Member
    Join Date
    Apr 2009
    Location
    Virginia Beach, Virginia
    Posts
    149
    Rep Power
    0

    Default

    Can you add three attributes from each member? Put an integer field in each member then increment it by one each time their data is wrote. Then check if the integer field is greater than or equal to three to test and see if you want to write the data.


    If it's three pieces of data all together then just keep a global variable that gets incremented and tested against.

    Why would you need the use of a loop for this?

  5. #5
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

Similar Threads

  1. While loop
    By verbazon in forum New To Java
    Replies: 5
    Last Post: 02-25-2009, 02:29 AM
  2. Need help with While Loop
    By mrdestroy in forum New To Java
    Replies: 14
    Last Post: 10-20-2008, 03:29 PM
  3. For Loop
    By kian_hong2000 in forum New To Java
    Replies: 1
    Last Post: 08-07-2008, 03:01 PM
  4. How to use While loop
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:44 PM
  5. A loop that doesn't loop
    By MichYer in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 09:44 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
  •