Pure Programmer
Blue Matrix


Cluster Map

Project: Julian Day Number

Write a function that computes the Julian Day Number given the month, day and year of a date of the proleptic Gregorian calendar. The Julian day is the number of days between the given date and November 24, 4714 BC in the proleptic Gregorian calendar. Assert preconditions that check for valid month, day and year values and postconition that the result is >= 0. Accept the month, day and year as command line arguments. Use negative years for BCE years such as -4713 = 4714BCE, -100 = 101BCE, -20 = 21BCE, and 0 = 1BCE all because there is no year 0 in the proleptic Gregorian calendar.

See [[Julian day]]

Output
$ javac -Xlint JulianDay.java $ java -ea JulianDay 11 24 -4713 11/24/-4713 = 0 Julian $ javac -Xlint JulianDay.java $ java -ea JulianDay 1 1 2000 1/1/2000 = 2451545 Julian

Solution