A simpler solution is:for (values = startvalue; values <= endvalue; values++) {System.out.print(values + ", ");count++;if (count == 5){System.out.print("\n");count = 1;}}Not tested though. Should anything be wrong I would guess count++; is the wrong side of the IF check... if it is printing 4 entries per line (Or 6 for that matter) try putting count++; after the IF check instead of before it :)
A simpler solution is:
ReplyDeletefor (values = startvalue; values <= endvalue; values++) {
System.out.print(values + ", ");
count++;
if (count == 5)
{
System.out.print("\n");
count = 1;
}
}
Not tested though. Should anything be wrong I would guess count++; is the wrong side of the IF check... if it is printing 4 entries per line (Or 6 for that matter) try putting count++; after the IF check instead of before it :)