Question
(30%) (a) (15%) Write a C# program that takes an integer m between 1 and 12 as the month number and prints out a calendar
(30%) (a) (15%) Write a C# program that takes an integer m between 1 and 12 as the month number and prints out a calendar like Figure 1 below. Show your design and code clearly in the Word file and also turn in your C# code. Do not use 7 Console.WriteLine() statements to print out this calendar (use for loop). You can use the fact that November 1 is on Tuesday. Since this is 2016, your calendar will show November, 2016 instead of November, 2014 with November 1 starting on Sunday
|
|
|
|
|
|
| |||||||
| November ,2014 |
|
|
|
|
| |||||||
|
|
|
|
|
|
|
| ||||||
|
|
|
|
|
|
|
| ||||||
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 | 29 |
| ||||||
30 |
|
|
|
|
|
|
|
Figure 1.
(15%) Test your program generating the calendar of 2017 for all twelve months, one calendar per month.
(15%) Class Date.
(5%) Add a new method int numberofDayssince1900 ( ) to class Date that returns the number of days since New Year of 1900 till the date of Date object d = new (day, month, year) that you specify. To be more specific you include the date of d, but not include the date of 1/1/1900. In particular this means numberofDayssince1900 ( ) returns 30 for 1/31/1900, 365 for 1/1/1901, 365 + 365 + 365 + 366 + 31 + 28 = 1520 for 3/1/1905.
(5%) Add 3 new methods isEarlier (Date), isLater(Date), and istheSame (Date) that compares two Dates object and determine which one comes first. Please implement these 3 methods based on the method numberofDayssince1900 ( ) in part (a).
(5%) Test your program with 3 different Dates in 2017, 2010, and 1900, and also two dates of your choice. Show the number of days since 1/1/1900, and which one is earlier, is later etc.
(14%) Enhance class Date to have
(7%) Three methods NextDay, NextMonth, NextYear. Note the NextDay method must handle the case when day is at the end of a month; NextMonth must handle the case when month is December (so next month is January).
(7%) Provide test cases to test NextDay, NextMonth, and NextYear. You need to show the NextDay, NextMonth, and NextYear of 5 different dates: today 10/31/17, 2/28/17, 2/29/16, Christmas eve, and New Years eve.
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