Reputation: 325
Basically, I want the if and else statements at the bottom to happen again when my counter reaches 13. How do I do it? My code is below.
int counter = 2;
int start = 19;
int end = 95;
while(!(input>=start && input<=end) /*range*/ && counter<100){
start+=95;
end+=95;
if(counter % 4 == 0)
end+=19;
else if(counter % 5 == 0)
start+=19;
counter++;
}
EDIT: Sorry for being unclear. Uhh, what I want to do is, if the if-else statements have already been executed 13 times, I want the whole thing, including the
start+=95;
end+=95;
to execute again.
Upvotes: 0
Views: 215
Reputation: 10250
int innerLoop=(counter==13)?2:1;
for (int i=0; i<innerLoop; i++) {
...
}
Upvotes: 0
Reputation: 345
wrap the codes in the loop into a method. when executes every 13 times, invoke the method again
Upvotes: 1