java - Math error switch always ends up zero -
i writing small program find day of week using gregorian math. following code outputs 0 switch statement resulting in same output each time.
this code:
isum = (centcode + iyear + (iyear /4) + monthcode + iday); ioutput %= isum; switch (ioutput) { case 0: sday = "sunday"; break; case 1: sday = "monday"; break; case 2: sday = "tuesday"; break; case 3: sday = "wednesday"; break; case 4: sday = "thursday"; break; case 5: sday = "friday"; break; case 6: sday = "saturday"; break; }
ioutput %= isum;
is short form of
ioutput = ioutput % isum;
which not want. guess want like
ioutput = isum % 7;
Comments
Post a Comment