diff options
| author | mo <mo.khan@gmail.com> | 2019-07-13 14:04:09 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-07-13 14:04:09 -0600 |
| commit | 9395e6d77fc2bdc26abd469d5c67fa4adb604bb9 (patch) | |
| tree | 9038843a3e8d8d1b5adc1aacd125062e88872298 /src/Q6 | |
| parent | a76b31a8639190c6e98fefc0e62e42b937501f94 (diff) | |
start work on Q6
Diffstat (limited to 'src/Q6')
| -rw-r--r-- | src/Q6/README.md | 32 | ||||
| -rw-r--r-- | src/Q6/WeekDay.java | 29 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/Q6/README.md b/src/Q6/README.md new file mode 100644 index 0000000..ed938ff --- /dev/null +++ b/src/Q6/README.md @@ -0,0 +1,32 @@ +Learning Profile for Assignment #2, And Question #6 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +```text +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: + +1. Calculate the total number of days from 1900/1/1 to the given date (see below for details). +1. 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: + +1. Subtract 1900 from the given year, and multiply the result by 365 +1. Add the missing leap years by adding (year − 1900) / 4. +1. If the year itself is a leap year and the month is January or February, you have to subtract 1 from the previous result. +1. 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). +``` + +1. Description of the Code: +1. Errors and Warnings: +1. Sample Input and Output: +1. Discussion: diff --git a/src/Q6/WeekDay.java b/src/Q6/WeekDay.java new file mode 100644 index 0000000..a4e27c8 --- /dev/null +++ b/src/Q6/WeekDay.java @@ -0,0 +1,29 @@ +package Q6; + +public class WeekDay { + private int numberOfDays; + public static final int JANUARY = 0; + public static final int FEBRUARY = 0; + public static final int MARCH = 0; + public static final int APRIL = 0; + public static final int MAY = 0; + public static final int JUNE = 0; + public static final int JULY = 0; + public static final int AUGUST = 0; + public static final int SEPTEMBER = 0; + public static final int OCTOBER = 0; + public static final int NOVEMBER = 0; + public static final int DECEMBER = 0; + + public static final int SUNDAY = 0; + public static final int MONDAY = 0; + public static final int TUESDAY = 0; + public static final int WEDNESDAY = 0; + public static final int THURSDAY = 0; + public static final int FRIDAY = 0; + public static final int SATURDAY = 0; + + public String getWeekDay(int day, int month, int year) { + return ""; + } +} |
