Question: Using C#, Write a program with a Date struct, that contains: Three fields: year, month, and day. All are int type. Two constructors: a. public

Using C#,

Write a program with a Date struct, that contains:

Three fields: year, month, and day. All are int type.

Two constructors:

a. public Date(int year, int month, int day) - takes three parameters, and assigns corresponding values in the struct.

b. public Date(string dateString). - takes a date string with format mm/dd/yyyy, such as 06/05/2017. You need to parse the string.

One method public void PrintInfomation() - It prints out the date information on the Console with the following format Today is Jun, 05, 2017.

In the Main method, first read an instruction number from the console, with option of 1 and 2.

1) For option 1, the program creates a Date struct using constructor a. User will then type in date information separated by spaces ( ), as 2017 06 05. The date information is printed using PrintInfomation() method.

2) For option 2, the program creates a Date struct use constructor b. User will then type in date information in the format of 06/05/2017. The date information is printed using PrintInfomation() method.

Example 1 (Bold lines are input):

1

2017 06 05

Today is Jun, 5, 2017

Example 2:

2

06/05/2017

Today is Jun, 5, 2017

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!