Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Programming 20 marks] Implement a Java method that prints out the day of the week for a given day (1...31), month (1.. . 12)
Java Programming
20 marks] Implement a Java method that prints out the day of the week for a given day (1...31), month (1.. . 12) and year in the range of March 1900 to February 2100. Calculate the day of the week for the dates between March 1900 and February 2100 as follows: First, you have to calculate the total number of days from 1900/1/1 to the given date (see below for details) Secondly, you divide this number by 7 with an integer remainder: This now is the day of the week, with 0 as Sunday, 1 as Monday, and so on. To calculate the total number of days, you have to implement the following steps: Subtract 1900 from the given year, and multiply the result by 365 Add the missing leap years by adding (year - 1900)/ 4. . If the year itself is a leap year and the month is January or February, you have to subtract 1 from the previous result. Now add all the days of the months of the given year to the result (in the case of February, it is always 28 because the additional day for a leap year has already been added in the calculation) WeekDay E Attributes + private int numberOfDays + public static final int APRIL public static final int AUGUST + public static final int DECEMBER + public static final int FEBRUARY + public static final int FRIDAY + public static final int JANUARY + public static final int JULY + public static final int JUNE + public static final int MARCH + public static final int MAY + public static final int MONDAY + public static final int NOVEMBER + public static final int OCTOBER + public static final int SATURDAY + public static final int SEPTEMBER + public static final int SUNDAY + public static final int THURSDAY + public static final int TUESDAY + public static final int WEDNESDAY E Operations + public String getWeekDay (int day, int month, int year)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