Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

6 Identify the sections of a classified balance sheet.

Answered: 1 week ago

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago