Results 1 to 4 of 4
Thread: loops
 02062011, 07:38 AM #1Member
 Join Date
 Feb 2011
 Posts
 9
 Rep Power
 0
 02062011, 07:54 AM #2
It's the modulus operator, which finds the remainder of a number when divided out into the second number.
So let's say you start with this: 7%2. To determine its value, you take 7, and subtract 2 until you cannot anymore. Like so:
7  2 = 5
5  2 = 3
3  2 = 1
(Can't subtract 2 anymore, since 1  2 < 0)
Therefore, 7%2 == 1. You'll also notice if you do long division for 7 divided by 2, the remainder will be 1. This holds true for any modulus operation.
In your case, basically it's checking to see if "i" is divisible by 5. That meas 5, 10, 15, ..... etc.
For more information:
Modulo operation  Wikipedia, the free encyclopedia
The Remainder or Modulus Operator in Java
modulus computing  Google Search
Good luck!
 02062011, 08:02 AM #3Member
 Join Date
 Feb 2011
 Posts
 9
 Rep Power
 0
so the following example case2 is just checking if the year is divisible by 4,100 and 400? I dont understand why are we doing this?
for (int m=1; m<=12; m++)
{
String monthN="";
int numD=0;
switch (m)
{
case 1:
monthN="January ";
numD=31;
break;
case 2:
monthN="February ";
if ((yr%4 == 0 && yr%100 != 0)  yr%400 == 0 )
numD=29;
else numD=28;
break;
case 3:
monthN="March ";
numD=31;
break;
 02062011, 01:45 PM #4
Last edited by j2me64; 02062011 at 02:09 PM.
Similar Threads

Help with loops!
By jrelvi23 in forum New To JavaReplies: 9Last Post: 09042012, 01:36 PM 
Help with loops
By pg5678pg in forum New To JavaReplies: 8Last Post: 10172010, 06:51 PM 
need some help with loops!
By Chewart in forum New To JavaReplies: 2Last Post: 12032009, 11:32 PM 
these loops...
By Blaedel in forum New To JavaReplies: 0Last Post: 10012009, 06:59 PM 
how to use do while loops
By mikeitalydz in forum New To JavaReplies: 32Last Post: 09262009, 08:30 PM
Bookmarks