ok I have an assignment that I don't understand.
I have to write a program that prompts the user for a date, and then displays how days ago it was from todays date. In julian days. It also has to continue to prompt for dates and process until the user wants to stop.
The algorithm for julian day number : Set jd, jm, jy to the day, month, and year. If the year is negative add 1 to jy (there is no year 0, year 1 BC was immediately followed by year AD 1). If the month is larger than february add 1 to jm. Otherwise, add 13 to jm and subtract 1 from jy. Then compute.
long jul = floor(365.25 * jy) + floor(30.6001 * jm) + d + 1720995.0
Store the result in a variable of type long (simple integers may not have enough digits to hold the value). If the date was before October 15, 1582 return this value, otherwise the following correction needs to be made:
int ja = 0,01* jy;
jul = jul + 2 -ja + 0.25 * ja ;
So I know I need to write a function
long julian(int year, int month, int day)
that converts the date into a julian day number. That's part of it. I just have no idea how to do this whole program.
I have to write a program that prompts the user for a date, and then displays how days ago it was from todays date. In julian days. It also has to continue to prompt for dates and process until the user wants to stop.
The algorithm for julian day number : Set jd, jm, jy to the day, month, and year. If the year is negative add 1 to jy (there is no year 0, year 1 BC was immediately followed by year AD 1). If the month is larger than february add 1 to jm. Otherwise, add 13 to jm and subtract 1 from jy. Then compute.
long jul = floor(365.25 * jy) + floor(30.6001 * jm) + d + 1720995.0
Store the result in a variable of type long (simple integers may not have enough digits to hold the value). If the date was before October 15, 1582 return this value, otherwise the following correction needs to be made:
int ja = 0,01* jy;
jul = jul + 2 -ja + 0.25 * ja ;
So I know I need to write a function
long julian(int year, int month, int day)
that converts the date into a julian day number. That's part of it. I just have no idea how to do this whole program.