-
Need help with loops
Hey guys i need help with loops for class. Pretty much i am trying to show some one their hourly pay in increments of 4. im having a tough time making it go up by four, heres my code.
Code:
public class Hourlypay
{
public static void main(String args[])
{
for (int p = 4; p <= 40; p++)
{
System.out.println(p + " ");
}
}
}
its not much but now its going up by one each time i need to make it go up by four.
-
Re: Need help with loops
Go back and look at this line:
Code:
for (int p = 4; p <= 40; p++)
How can you make it increment by 4?
-
Re: Need help with loops
Code:
for(int i = 0; i < 40; i = i + 4)
-
Re: Need help with loops
Quote:
Originally Posted by
Amok
Code:
for(int i = 0; i < 40; i = i + 4)
Amok, don't spoonfeed. Moreover, that's bad code inasmuch as i = i + 4 is not the syntax commonly used for incrementing a numeric variable.
db