Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will implement a date and day of week calculator for the 2013 calendar year. The calculator repeatedly reads in three numbers (in a line)

You will implement a date and day of week calculator for the 2013 calendar year. The calculator repeatedly reads in three numbers (in a line) from the standard input that are interpreted as month dayofmonth daysafter, calculates the dates in the year and days of week for the dates, and outputs the information
image text in transcribed
image text in transcribed
image text in transcribed
Do it in C#
c#
Date and day of week calculator Objectives Implement a simple class with public and private members and multiple constructors. Gain a better understanding of the building and using of classes and objects. Practice problem solving using OOP. Overview You will implement a date and day of week calculator for the 2019 calendar year. The calculator repeatedly reads in three numbers in a line) from the standard input (from textbox) that are interpreted as month dayofmonth daysafier, calculates the dates in the year and days of week for the dates, and outputs the information. For example, input "1131" is interpreted as the following: the first 1 means the 1st month in the year, January, the second 1 means the 1" day in January; and the 31 means 31 days after the date January 1, 2019 (we assume the year is 2019 to simplify the program), which is February 1, 2019. The program also calculates the days of week for each of the dates. More specifically, for input "11 31", the calculator should produce the following output: "31 days after Tuesday, January 1, 2019 is Friday, February 1, 2019." The first input number must be from 1 to 12 representing the 12 months in 2019, the second input number must be a day in the month (e.g. for 1-31 for January, 1-28 for February, and so forth). The third number is larger than or equal to 0. The program should report an error and exit) if the input is incorrect. If a day is not in 2019, the program should output that. Following are a sample input file (redirect to be the standard input) and the corresponding output. Input file: 11 20 1131 210 11 32 45 0 2 1 28 11 59 6 10 100 7 20 300 12 202 Output: 20 days after Tuesday, January 1, 2019 is Monday, January 21, 2019. 31 days after Tuesday, January 1, 2019 is Friday, February 1, 2019. 0 days after Friday, February 1, 2019 is Friday, February 1, 2019. 32 days after Tuesday, January 1, 2019 is Saturday, February 2, 2019. 0 days after Friday, April 5, 2019 is Friday, April 5, 2019. 28 days after Friday, February 1, 2019 is Friday, March 1, 2019. 59 days after Tuesday, January 1, 2019 is Friday, March 1, 2019. 100 days after Monday, June 10, 2019 is Wednesday, September 18, 2019. 300 days after Saturday, July 20, 2019 is a date not in 2019. 2 days after Friday, December 20, 2019 is Sunday, December 22, 2019. Details 1. This project has two components. The first component is to implement a date 2019 class specified in the following, The second component is a driver program that uses the date 2019 class to realize the calculator. 2. The date2019 class should have two private data members of the int type, d and m with m encoding the month (1 - January, 2-February, ...) and d being the day in the month. For example to represent April 5, d = 5, m =4. To represent a date not in 2019, m=-1, d=-1. 3. The date2019 class should have the following public functions: date 20190; date2019(int dd); date2019(int dd, int mm); void setdate(int dd, int mm); void print(); void plusday(int days); 4. The default constructor date20190) should set the default date of the object to be January 1, 2019. 5. The parameter for the constructor with 1 parameter date 2019(int dd) ranges from 1 to 365 (the code should ule2019 Uurales IIUM I IU JUS We Love StoUIU report error and exit if the parameter is not in the range) and is day of year for the date in 2019. The constructor converts day of year to month and day of month. For example the 70 day of the year is March 11: the constructor should make m =3 and d= 11 when date2019(70) is invoked. 6. For the two parameter constructor date 2019(int dd, int mm), you just need to make sure that month (mm) and day (dd) are legitimate and set d=dd, and m=dd. If either the day or the month is not legitimate, the code should report error and exit. 7. Setdate is similar to the two parameter constructor. 8. The print() function calculates the day of week for the date 2019 object and output to the standard output the date in the form of dayofweek, month day, 2019'. For example, when the object have d=1, m=1, the print should output "Tuesday, January 1, 2019". For a date not in 2019 (m=-1 and d=-1), this routine should output a date not in 2019". 9. The plusday(int days) function modifies the m and d for the new date, which is days after the current date. Submission The due time for this assignment is 27 December 2019. Hints 1. To compute the date for X days after the current date, one can convert the current date into the day of year by adding up all days in the previous months and the day in the month, add X to the day of year to obtain the new day of the year, and then convert it back to the month and day of month representation (using the reverse computation process to convert current date to day of year). For example, the day of year for April 5 is daysinmonth[Jan] + daysinmonth[Feb] + daysinmonth[March] +5. 2. To compute day of the week for a given date, one can have the following encoding: 0 - Sunday, 1-Monday, 2- Tuesday, 3-Wednesday, 4-Thursday, 5-Friday, 6- Saturday. Using this encoding, one can first convert the date into day of year, let it be X. Since January 1, 2019 is a Tuesday, the encoded day of week=(2 +X-1) % 7

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

Students also viewed these Databases questions

Question

1. Describe the power of nonverbal communication

Answered: 1 week ago