Question
There's a way of calculating the Julian day daynum of a year: the ordinal number of any date within the year. (January 1 is always
There's a way of calculating the Julian day daynum of a year: the ordinal number of any date within the year. (January 1 is always Julian day 1.) Use int arithmetic and assume that 1 is the value of month for January, 2 for February, and so forth:
(a) daynum=31(month1)+day
(b) If the month is after February subtract (4(month) + 23)/10 **[no final parenthesis]
(c) If its a leap year and after February 29, add 1 Do the calculation assuming the entered year is NOT a leap year (skip step (c)).
Implement this as a method public static int julian(int day,int month,int year) which returns the Julian day of its date argument. Define a main() method which reads the date from the user as three separate int values, then calls your function and prints the result. You don't have to verify that it's valid.
d) add the leap year calculation and validate the input, printing an error message if it isn't a valid date.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started