Question: Write a program Calendar.java that takes two command line arguments m and y and prints out the monthly calendar for the mth month of year
Write a program Calendar.java that takes two command line arguments m and y and prints out the monthly calendar for the mth month of year y. You should only use conditionals and loops (no arrays as we have not coverd it yet). For example, your output for Calendar 2 2009 should be:
--------------------- February 2009 --------------------- Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ---------------------
This is what i do know: During leap years, an extra day is added to the 28 days of February. A year is a leap year if it is either divisible by 400 or divisible by 4 but not 100. e.g: 2000 and 2004 are leap years, but 1900 is not.
Day of Week: Given a month m, a day d, and a year y, the corresponding day of the week is computed as follows:
y0 = y - (14 - m) / 12 x = y0 + y0/4 - y0/100 + y0/400 m0 = m + 12 * ((14 - m) / 12) - 2 d0 = (d + x + (31*m0)/12) mod 7 // 0 for Sunday, ..., 6 for Saturday
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
