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
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