Results 1 to 7 of 7
Thread: a while loop
 11112010, 02:55 PM #1Member
 Join Date
 Nov 2010
 Posts
 24
 Rep Power
 0
a while loop
Hello
So I need a while loop, what I have are some fields:
An integer x, another integer b, a maximum limit, and a minimum limit (all ints).
What I need to do is:
When x is smaller than the minimum limit, I need to multiply x by 6, and add 2 to the integer b. I need to keep doing this, until x is between the minimum and maximum limits, then stop and print out the number.
I am confused how to do this.
What I have so far is this:
Java Code:while(x < minimum) { x = x*6; b = b + 2; }
Any help would be much appreciated
 11112010, 03:03 PM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
 11112010, 03:10 PM #3Member
 Join Date
 Nov 2010
 Posts
 24
 Rep Power
 0
Thanks, okay I'm now supposed to add an extra bit which will stop the while loop either when x is big enough, or, when b reaches a certain number, (whichever is sooner). how can I do that?
 11112010, 03:19 PM #4Senior Member
 Join Date
 Feb 2009
 Posts
 312
 Rep Power
 11
Java Code:while (x isn't big enough  b is less than a certain number) { //do stuff... }
 11112010, 03:25 PM #5Member
 Join Date
 Nov 2010
 Posts
 24
 Rep Power
 0
Thanks a lot
 11112010, 03:37 PM #6
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
 11112010, 03:51 PM #7Senior Member
 Join Date
 Feb 2009
 Posts
 312
 Rep Power
 11
Similar Threads

for loop help
By soc86 in forum New To JavaReplies: 9Last Post: 01242011, 09:45 PM 
Loop Help Please
By JavaAssistance in forum New To JavaReplies: 11Last Post: 09262010, 10:05 PM 
How can I rewrite the following while loop using a for loop?
By gt11990 in forum New To JavaReplies: 5Last Post: 04302010, 05:05 PM 
whileloop stopping on first loop
By davester in forum New To JavaReplies: 6Last Post: 06262009, 08:46 PM 
while loop
By Unknown1369 in forum New To JavaReplies: 5Last Post: 07082008, 10:15 AM
Bookmarks