The Task Write a Java program called DaysApart, which will ask for two dates from the user, and print out the number of days between the two dates. The range of dates that the program must accept are from 1900/01/01 to 2099/12/31.
If you attempt the basic version of the assignment, then your program only needs to calculate the number of days between two dates in the same year. If you attempt the advanced version of the assignment, then your program needs to calculate the number of days between any two dates in the range 1900/01/01 to 2099/12/31 inclusive.
Specific Subtasks Your program must contain a method called isLeap(), which takes a year integer parameter, and returns a boolean result which is true if the year is a leap year, or returns false if the year is not a leap year.
Your program must contain a method called isValidDate(), which takes three integer parameters representing the date (year, month, day), and returns true if the date is a valid date, or false if the date is not valid.
A date is an invalid date if it does not represent a date within the range 1900/01/01 to 2099/12/31 inclusive, or if it does not represent a valid date within the given year (e.g. 2006/45/-1 or 2006/2/30).
Your program must contain a method called dayNumber(), which takes three integer parameters representing the date (year, month, day), and returns the number of that day within the given year. For example, the 1st of January is always day 1, and the 31st of December is day number 365 in normal years, or day number 366 in leap years. If the input date is invalid, the method must return the number -1 to indicate that the date is invalid.
Your program must contain a method called daysApart(). This method takes six integer parameters representing two dates, and returns the number of days between the two dates as a positive number. If either of the input dates are invalid, the method must return the number -1 to indicate that one of the dates is invalid.
If you are only attempting the basic version of this assignment, then the method must also return -1 if the dates are from different years.
Your main() method is the only method which is allowed to read input from the user, and the only method which is allowed to print information out to the user. Each time the main() method reads in a date from the user, it must check the date. If the input date is invalid, the main() method must print out the message "That date is invalid!" and stop.
---------------------------------------
How hard is it for a begginer to do all of this? Im trying my best to get bonus marks in my computer science class at high school.
It's not really complicated - if you know how to create methods in Java and set parameters and return types.
The text describes more or less every step you have to do inside the methods.
One hint: Crate an int-Array with 12 fields, every field contains the number of days of each month. This will easy a lot of the operations. Note: When accessing this array, use monthNr-1 as index.