Results 1 to 5 of 5
Thread: Loop, is it what I need?
- 04-14-2009, 03:50 AM #1
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
-
members? Perhaps a clarification of terms and concepts will help us here.
- 04-14-2009, 04:03 AM #3
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
- 04-14-2009, 04:26 AM #4
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?
- 04-14-2009, 04:28 AM #5
Similar Threads
-
While loop
By verbazon in forum New To JavaReplies: 5Last Post: 02-25-2009, 01:29 AM -
Need help with While Loop
By mrdestroy in forum New To JavaReplies: 14Last Post: 10-20-2008, 02:29 PM -
For Loop
By kian_hong2000 in forum New To JavaReplies: 1Last Post: 08-07-2008, 02:01 PM -
How to use While loop
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:44 PM -
A loop that doesn't loop
By MichYer in forum New To JavaReplies: 2Last Post: 07-30-2007, 08:44 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks