0
Calendars Java
Can someone help me complete this java code? Implement the following functions: 1 part (Basic) • int isLeap(int year) returns 1 if year is a leap year, -1 if invalid and 0 otherwise • int daysInMonth(int year, int month) returns the number of days in month of year, or -1 if date is invalid. • int checkDate1(int year) returns whether the given year is valid, i.e. returns 1 if date is valid, and 0 otherwise. • int checkDate(int year, int month) returns whether the given month in the give year is valid, i.e. returns 1 if date is valid, and 0 otherwise. • int checkDate(int year, int month, int day) returns whether the given date is valid, i.e. returns 1 if date is valid, and 0 otherwise. Code: https://code.sololearn.com/c8TMI53l1ByD/#java
3 Réponses
0
2 part (Calculation)
• int ymd2w(int year, int month, int day) calculates the weekday of a given date. The
date is passed to the function as three integers. Returns the weekday according to Table 1 in
Weekdays exercise or -1, if date is invalid.
• int dayNumber(int year, int month, int day) returns the day count, or -1 if the given
date is invalid. The day count is the number of days passed since the start of the year plus
one. E.g.: Jan, 1 st is day 1 in any year; Dec. 31 st is day 365 in a non-leap year and day
366 in a leap year.
• int weekNumber(int year, int month, int day) returns the week number of a given
date, or -1 if date is invalid. Week 1 in any year is the week of Jan, 1 st .
0
3.part (Output)
• void printDayName(int day) prints the name of day. The name of a day is given in Table 1
in Exercise Weekdays. prints invalid day(<day>) if day is not in the range 0-6. The output
produced contains no whitespace or other additional characters before or after the name.
The names are the full English names, e.g. “Monday”, “Friday”. . .
• void printMonth(int month) prints the name of month. The months accepted are in the
range 1-12, 1 being January. prints invalid day(<month>) if month is not in the range 1-12.
The output produced contains no whitespace or other additional characters before or after
the name. The names are the full English names, e.g. “January”, “February”. . .
• void printNmberEnding(int n) prints the English number ending for n the number ending
is:
– st for numbers ending with 1, except 11
– nd for numbers ending with 2, except 12
– rd for number ending with 3 except 13
– th otherwise
• void printDate(int year, int month, int day) prints a given date in the following
format: <Weekday>, <Month> <day> <number_ending> <year> prints invalid date
(<day><month>.<year>). for invalid dates.
• void printStatistics(int year, int month, int day) prints various information on the
given date:
– date as described in printsDate(int,int,int)
– the year and whether it is a leap year or not
– the number of days in the month of the given date
– the number of the day
– the week of the date
prints invalid date. for invalid dates.
0
4 part (Applications)
• void printCalendar(int year, int month, int day, int highlight) prints a calendar of the month of the given date. Each line of the calendar displays one week. The weeks in the calendar start on Monday. if highlight is set, the given date is highlighted with
brackets <>in the calendar. Example April 2000