Shoutbox

Java programming help needed - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: General (/forumdisplay.php?fid=11)
+---- Forum: General Chit Chat (/forumdisplay.php?fid=14)
+----- Thread: Java programming help needed (/showthread.php?tid=41547)

Java programming help needed by Vilkku on 03-30-2005 at 05:02 PM

Okey, I got this exersice. We are supposed to make a program that asks the user for a year and the program will tell if it is one of those years with an extra day (forgot what it's called). We are supposed to do it with boolea, and theese are the requirements for the year:

code:
(DivideableWith4 && !DivideableWith100) || DivideableWith400

Now, how can I easily get the program to check if it is possible to divide a number with those?
RE: Java programming help needed by CookieRevised on 03-30-2005 at 06:19 PM

quote:
Originally posted by Vilkku
We are supposed to make a program that asks the user for a year and the program will tell if it is one of those years with an extra day (forgot what it's called)
a leapyear.

quote:
Originally posted by Vilkku
We are supposed to do it with boolea, and theese are the requirements for the year:
code:
(DivideableWith4 && !DivideableWith100) || DivideableWith400
Now, how can I easily get the program to check if it is possible to divide a number with those?
divide the number and check if there is a remainder.

This can either be done by comparing the integer division with a floating point division. eg:
   floatingpoint = 101 / 4
   integer = 101 \ 4
   If floatingpoint == integer Then IsDivideableBy4

Or by the MOD function. eg:
  If (101 MOD 4) * 4 = 101 Then IsDivideableBy4

Or maybe Java even has function which directly returns the remainder of a division (dunno). eg:
  Remainder = 101 XXX 4
  If Remainder = 0 Then IsDivideableBy4